In a special scenario wherein the resold customer who is using Google Vault, GoogleDrive along with Google Apps for Business, and to transfer that customer, as per the documentation (Ref https://developers.google.com/admin-sdk/reseller/v1/how-tos/batch) we're supposed to use Batch Subscription Ordering.
Here is what we're observing so far:
- When we try to transfer resold customer which has only one subscription “Google-Apps-For-Business” a. Then the Batch Ordering (even though its not required) is working.
- However when we have to transfer resold customer who has more than on subscription such as “Google-Apps-for-Business” and one or more of “Google Vault”, “Google drive” a. If we send all features request with Batch Order, the call retunes Error Code: 500 (Internal Server Error) b. If we send only one request (even though it is wrong as per the documentation) in the Batch Order (the Google-apps-for-business), the call returns expected Error Code: 412 (Precondition Failed): The domain has subscriptions which need to be transferred.
We also tried based on the Google Calendar API Example (Ref https://developers.google.com/admin-sdk/reseller/v1/how-tos/batch) but it also results in the same failure.
Both above suggests either the documentation is wrong or the API doesn't work as per the documentation.
Does anyone have a suggestion?
Here is the sample code
// 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();