What does this Google API error message mean? - google-api

Imagine you call an API to get an in-app purchase details. It has 3 params: package name (de facto app ID), product ID and a purchase token.
You get the following response: HTTP 400 Invalid Value with JSON body like this:
[{'message': 'Invalid Value', 'domain': 'global', 'reason': 'invalid'}]
Is your package name invalid? Is your product ID invalid? Or is your purchase token invalid?
Hint: all of the values you passed are valid.
Question: what is wrong?

Answer: you're calling an incorrect API method. The purchase was not a product, it was a subscription.
I've wrote a ton of APIs myself and I would never ever return a HTTP 400 with such confusing output.
Google, you can do better.

Related

Filter envelopes by email docusign

I need retrieving all the envelopes that have been signed or sent to an email.
I was trying to do this using the 'accounts/{account_id}/envelopes' endpoint passing the 'search_text' query param. As in the example in documentation https://developers.docusign.com/esign-rest-api/guides/concepts/envelopes/search
/v2.1/accounts/{account_id}/envelopes?search_text=Tabs
But I'm getting always error 400 - INVALID_REQUEST_PARAMETER. Am I doing this in the wrong way?
I think 4644 is most likely not your account ID. can you check what is your account ID?
Also, add :
&from_date=2019-03-04T00:00:00.000Z&to_date=2019-03-07T00:00:00.000Z

What is the correct spelling of the session token parameter for Google Places API requests?

The documentation for the session token for the Google Places API refers to the parameter as both sessiontoken and session_token throughout the document. Which one is correct?
Making a request with both sessiontoken and session_token parameters included results in:
{
"error_message": "Invalid request. Only one of the 'sessiontoken' or 'session_token' parameters are allowed.",
"predictions": [],
"status": "INVALID_REQUEST"
}
So apparently either one is acceptable.

REST HTTP Status Code Best Practice for validation API

I am creating a simple API to validate a membership. Client will have to input a String ID and Server will check if the ID is a valid member of our, lets say, community. The ID must be numeric only, with length 10.
Quite simple right?
If the ID is a valid, of course we will return HTTP Status Code OK.
If the ID is contains alfabet, or less/more than 10, then we will return HTTP Status Code BAD REQUEST.
The question is, what is the best practive HTTP Status Code to return when the ID is numeric and length = 10, but is NOT a member of our community? and why is that.
The endpoints of a REST API are normally resources on which you act using HTTP methods like GET,PUT,POST,DELTE. When you do it like that, its much easier to decide which HTTP status to return.
So may be you could make an endpoint
/member/{id}
if a member with this id exists, return HTTP 200 and if you want some JSON with basic member info
if the id is valid, but no member exists, return HTTP 404 - NOT FOUND
if the id is not valid, length !=10 or contains invalid chars, return a HTTP 400 BAD REQUEST
Here you can find more about REST API design

How to specify error codes in Apiary Documentation?

I want to specify the various exceptions/errors that have to be returned while making an API call. How do I achieve this with Apiary.
Kyle's response is indeed correct. I will just add that if you want to add little bit more semantics to this you can write the other possible responses like this:
## POST /users/resendVerification/{userId}
Resends the user's verification code to the email address on record.
+ Response 201
+ Response 403
Returned if the user does not have access to the requested account
+ Body
+ Response 404
Returned if a user was not found for the given userId
+ Body
Note: The + Body is needed (even though it is empty) to distinguish the description from a message-body.
I'm not aware of a specific syntax for error codes. In the past I've simply used bullet points. For example, this is my code for a re-request verification code API.
## POST /users/resendVerification/{userId}
Resends the user's verification code to the email address on record.</br>
• 403 is returned if the user does not have access to the requested account</br>
• 404 is returned if a user was not found for the given userId</br>
+ Response 201
Hope that helps.

Inapppurchases: get api query failed "code":400,"message":"Invalid Value" "code":500,"message":null

I get access_token by this way :https://developers.google.com/android-publisher/authorization
1.use google account allow acess get code
2.use code to get refresh_token
3.use refresh_token get access_token
when use this api
$url_purchase = "https://www.googleapis.com/androidpublisher/v1.1/applications".
"/$packageName/inapp/$productId/purchases/$token?access_token=".
$return_data->access_token;
$return_purchase = http_get($url_purchase);
some billing return
{"error":{"code":500,"message":null}}
some billing return
{"error":{"errors":[{"domain":"global","reason":"invalid","message":"Invalid Value"}],"code":400,"message":"Invalid Value"}}
but some billing can success return
{"kind":"androidpublisher#inappPurchase","purchaseTime":"1395035642794","purchaseState":0,"consumptionState":1}
I think the access_token is right, why some billing failed . someone can help me ?thanks very much.
Are there any other way to check billing valid on the server?

Resources