I'm working with "Save to Android Pay" API and I'm trying to update one of my objects. According to Google's API.
One way to achieve it is by using the cURL commands and follow these steps:
java -jar TokenUtil.jar serviceAccountEmailAddress pathToPrivateKey
curl -X GET https://www.googleapis.com/walletobjects/v1/walletObjectType/resourceId -H "Authorization: Bearer bearerToken" > myobjectfile.txt
curl -X PUT https://www.googleapis.com/walletobjects/v1/walletObjectType/resourceId -H "Authorization: Bearer bearerToken" -H "Content-Type: application/json" -d myobjectfile.txt
Steps 1 - 3 work fine but when I try to push the object back to the server I get the following error:
{
"error": {
"errors": [
{
"domain": "global",
"reason": "parseError",
"message": "Parse Error"
}
],
"code": 400,
"message": "Parse Error"
}
}
Since all I changed in the file is the version (and maybe one character in some title, just to see change) I do not understand why am I getting a parse error as myobjectfile.txt
came from the server and its internal structure was not built by me.
It took them a while but Google finally solved their bug and shared their solution with me (hopefully they will update their API soon, too):
• The file should be a .json
file rather than a .txt
file.
• There should be an @
sign before the file name in the PUT command:
curl -X PUT https://www.googleapis.com/walletobjects/v1/walletObjectType/resourceId -H "Authorization: Bearer bearerToken" -H "Content-Type: application/json" -d @myobjectfile.json
After applying these changes, I was able to update my object.