根据文档(参考https://developers.google.com/admin-sdk/reseller/ v1/how-tos/batch)我们应该使用批量订阅订购。
以下是我们目前观察到的情况:
- 当我们尝试转移只有一个订阅“Google-Apps-For-Business”的转售客户时 然后批量订购(即使它不是必需的)正在工作。
- 但是,当我们必须转移拥有超过订阅数量的转售客户时,例如“Google-Apps-for-Business”以及“Google Vault”、“Google drive”中的一个或多个。如果我们使用 Batch Order 发送所有功能请求,则调用会重新调整错误代码:500(内部服务器错误) b。如果我们在批处理订单(Google-apps-for-business)中只发送一个请求(即使根据文档是错误的),调用会返回预期的错误代码:412(前提条件失败):域有订阅需要转移。
我们还尝试了基于 Google Calendar API 示例(参考https://developers.google.com/admin-sdk/reseller/v1/how-tos/batch),但它也会导致同样的失败。
以上两者都表明文档有误,或者 API 不能按照文档工作。
有人有建议吗?
这是示例代码
// based on https://code.google.com/p/google-api-java-client/wiki/Batch sample code
Reseller reseller = Reseller.Builder(httpTransport, jsonFactory, credential).setApplicationName("RedResellerAccountSample").build();
JsonBatchCallback<Subscription>; callback = new JsonBatchCallback<Subscription>() {
@Override
public void onSuccess(Subscription t,
HttpHeaders responseHeaders) throws IOException {
// TODO Auto-generated method stub
System.out.println("Success");
}
@Override
public void onFailure(GoogleJsonError e,
HttpHeaders responseHeaders) throws IOException {
// TODO Auto-generated method stub
System.out.println("Failure");
}
};
BatchRequest batchRequest = reseller.batch();
Subscription sub = new Subscription();
sub.setKind("subscriptions#subscription");
sub.setCustomerId("testdomain.com");
Subscription.Plan plan = new Subscription.Plan();
plan.setPlanName("TRIAL");
Seats seats = new Seats();
seats.setKind("subscriptions#seats");
seats.setMaximumNumberOfSeats(10);
sub.setPlan(plan);
sub.setSeats(seats);
sub.setSkuId("Google-Apps-For-Business");
reseller.subscriptions().insert("testdomain.com",sub).setCustomerAuthToken("B40D2EFF4316B703").queue(batchRequest, callback);
Subscription sub2 = new Subscription();
sub2.setKind("subscriptions#subscription");
sub2.setCustomerId("testdomain.com");
Subscription.Plan plan2 = new Subscription.Plan();
plan2.setPlanName("TRIAL");
Seats seats2 = new Seats();
seats2.setKind("subscriptions#seats");
seats2.setMaximumNumberOfSeats(10);
sub2.setPlan(plan);
sub2.setSeats(seats);
sub2.setSkuId("Google-Vault");
reseller.subscriptions().insert("testdomain.com",sub2).setCustomerAuthToken("B40D2EFF4316B703").queue(batchRequest, callback);
//System.out.println(new ObjectMapper().writeValueAsString(batchRequest);
// if we call it fail as we have more than one request queued in the
batchRequest.execute();