我正在尝试插入新订阅,主要是为了更改许可证的座位数。我正在使用 v2 许可 API,代码如下:
AppsMarketService service = new AppsMarketService();
service.appId = "appID";
service.appName = "someDomain";
service.endpoint = "https://www.googleapis.com/appsmarket/v2/";
service.consumerKey = service.appId + ".apps.googleusercontent.com";
service.consumerSecret = "somethingSecret";
service.authorize();
CustomerLicense cl = service.getCustomerLicense("company.com", true);
Subscription sub = new Subscription();
sub.subscriptionId = "subID";
sub.applicationId = service.appId;
sub.name = "Full";
sub.description = "Full service";
sub.currencyCode = "USD";
sub.customerId = cl.customerId;
sub.initialCart = new InitialCart();
sub.initialCart.cart = new Cart();
sub.initialCart.cart.receiptName = "Receipt name";
sub.initialCart.cart.receiptDescription = "Receipt description";
LineItem item = new LineItem();
item.name = "My Subscription";
item.description = "Subscription billing for the App";
item.editionId = "default_edition";
item.seatCount = 100;
item.price = 100L;
sub.initialCart.cart.items = new ArrayList<LineItem>();
sub.initialCart.cart.items.add(item);
Subscription response = service.insertSubscription(sub);
它与此处提供的示例非常相似,只是我没有设置购买令牌,因为我没有它。还没有人购买。我已经调试了对HttpRequest.execute()的insertSubscription调用,响应是:
-------------- RESPONSE --------------
400
X-Frame-Options: SAMEORIGIN
Date: Thu, 02 May 2013 18:44:07 GMT
Content-Length: 139
X-XSS-Protection: 1; mode=block
Expires: Thu, 02 May 2013 18:44:07 GMT
Content-Encoding: gzip
Content-Type: application/json; charset=UTF-8
Server: GSE
X-Content-Type-Options: nosniff
Cache-Control: private, max-age=0
02.05.2013. 20.44.07 com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: /licensing: com.google.api.client.http.HttpResponseException: 400
所以基本上没有错误信息说明出了什么问题。有什么线索吗?
PS 显示如何更新许可证的默认版本也会有所帮助。