user1507748
user1507748

Reputation: 91

getting a 500 error when using google purchasing REST API

I'm developing an android app that uses Google Play's new subscription feature. Part of my app consists of a web server that periodically checks the status of these subscriptions via an API call. It also cancels some of these subscriptions.

Google provides two REST APIs to accomplish this:

https://developers.google.com/android-publisher/v1/purchases/get

https://developers.google.com/android-publisher/v1/purchases/cancel

I can get the first one to work great, using OAuth. However when I try to cancel certain subscriptions, I get a 500 error with no details. Has anyone else experienced this? Am I using it incorrectly? I'm sure the OAuth is working because I can hit the first API. Here is my curl output, with some of my account data concealed:

curl -X POST 'https://www.googleapis.com/androidpublisher/v1/applications/com.ssd.mypkg/subscriptions/mysku/purchases/mypurchasetoken/cancel' -H 'Authorization: OAuth ya29.myoauth' -d '' -v
* About to connect() to www.googleapis.com port 443 (#0)
*   Trying 209.85.148.95... connected
* Connected to www.googleapis.com (209.85.148.95) port 443 (#0)
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS handshake, Server hello (2):
* SSLv3, TLS handshake, CERT (11):
* SSLv3, TLS handshake, Server finished (14):
* SSLv3, TLS handshake, Client key exchange (16):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSLv3, TLS change cipher, Client hello (1):
* SSLv3, TLS handshake, Finished (20):
* SSL connection using RC4-SHA
* Server certificate:
*    subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN=*.googleapis.com
*    start date: 2012-06-14 06:42:53 GMT
*    expire date: 2013-06-07 19:43:27 GMT
*    subjectAltName: www.googleapis.com matched
*    issuer: C=US; O=Google Inc; CN=Google Internet Authority
*    SSL certificate verify ok.
> POST /androidpublisher/v1/applications/com.ssd.mypkg/subscriptions/mysku/purchases/mypurchasetoken/cancel HTTP/1.1
> User-Agent: curl/7.21.4 (universal-apple-darwin11.0) libcurl/7.21.4 OpenSSL/0.9.8r zlib/1.2.5
> Host: www.googleapis.com
> Accept: */*
> Authorization: OAuth ya29.myoauth
> Content-Length: 0
> Content-Type: application/x-www-form-urlencoded
> 
< HTTP/1.1 500 Internal Server Error
< Content-Type: application/json; charset=UTF-8
< Date: Fri, 06 Jul 2012 15:23:10 GMT
< Expires: Fri, 06 Jul 2012 15:23:10 GMT
< Cache-Control: private, max-age=0
< X-Content-Type-Options: nosniff
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< Server: GSE
< Transfer-Encoding: chunked
< 
{
 "error": {
  "code": 500,
  "message": null
 }
}
* Connection #0 to host www.googleapis.com left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):

Upvotes: 9

Views: 2205

Answers (3)

ManInTheBox
ManInTheBox

Reputation: 174

I can confirm the same issue. This is the response I received:

{
  "error": {
    "code": 500,
    "message": null
  }
}

I think the reason for this awkward error message is that the subscription is not valid anymore, but we tried to cancel it. Instead, we should first check if subscription is valid: expiration date, cancellation reason, auto renewing.

In my particular case, the subscription expired and cancelReason is 1 meaning it was cancelled by the system.

Upvotes: 1

weemattisnot
weemattisnot

Reputation: 919

I am also encountering this error. My app is only published in beta-testing mode. Could that be the problem, I wonder?

In case it is relevant, I am using a modified version of googlesamples/android-play-publisher-api where I changed basic_list_apks to act as a subscription revoker, by modifying the service-call defining line to be like this:

service.purchases().subscriptions().revoke(packageName=package_name,
    subscriptionId=product_id,
    token=purchase_token)

Upvotes: 1

Frank
Frank

Reputation: 21

I can confirm having exactly the same issue. getting details works perfecty but canceling fails. I am using the Google API for java classes, so I think that this is a general issue we should post as a bug to google.

Here is the response I receive from google server:

com.google.api.client.googleapis.json.GoogleJsonResponseException: 500 Internal Server Error
{
  "code" : 500,
  "message" : null
}

Upvotes: 2

Related Questions