Can anyone shed some light on what is wrong with my google wallet object create JSON ?
I get an error attempting to create a google wallet pass object that suggests the field 'id' is malformed. I am certain there is nothing wrong with the field.
I've tried different pass types including Loyalty and Generic, and various different types of 'id' field value ( even removing it, and even removing all fields ), but get the same error.
To create the pass, the authentication is passed as a header which must be fine as other API calls work without issue, and the URL for Object creation is :
https://walletobjects.googleapis.com/walletobjects/v1/genericObject
The JSON i am using to create the pass is :
{ "cardTitle": { "defaultValue": { "language":"en-GB", "value":"My Company" }},"header": { "defaultValue": { "language":"en-GB", "value":"Loyalty Card" }}, "logo": { "sourceUri": { "uri": "https://www.mycompany.com/lib/img/logo.png", "description":"company logo" } }, "hexBackgroundColor": "#b03030", "classId": "3388000000022122130.pass.mycompany.test.loyalty1", "id": "277210000034", "barcode": {"type":"QR_CODE", "value":"277210000034", "alternateText":"277210000034" }, "heroImage": { "sourceUri": { "uri": "https://www.mycompany.com/lib/img/logo.png", "description":"company background" } }, "textModulesData": [ { "header":"Header One", "body":"Body One" } ], "state": "ACTIVE" }
The response is:
{ "error": { "code": 400, "message": "not a valid id: ", "errors": [ { "message": "not a valid id: ", "domain": "walletobjects", "reason": "invalidResource" } ] } }
I suspect the 'id' it is complaining about should appear in some other element than the top level 'id' field, but the error returned from google gives little away as to where the problem is.
The documentation for google wallet generic passes is here :
The problem was nothing to do with my JSON payload. It was caused by a missing header in my CURL HTTP request.
The Content-Type was not being set, the following CURL option fixed the problem :