google-wallet / passes-rest-samples

Server-side samples for the Google Pay API for Passes
Apache License 2.0
95 stars 49 forks source link

addmessage to object gives error #41

Closed Eleftheria-99 closed 2 years ago

Eleftheria-99 commented 2 years ago

Hello, I am trying to use this endpoint : https://developers.google.com/wallet/tickets/events/rest/v1/eventticketobject/addmessage, in order to send a message to the user that has added the pass ij the GPay. I am building the message body like this : message: { kind: "walletobjects#walletObjectMessage", header: header, body: body, // displayInterval: { // kind: "walletobjects#timeInterval", // start: { // date: start_date // }, // end: { // date: end_date // } // }, id: "message_id", messageType: { type: "string", enum: ["NOTIFICATION_EXPIRY"] } } and I am always getting this error :

  code: 400,
   errors: [
     {
         message: "Invalid value at 'add_message_request.message' (message_type), Starting an object on a scalar field",
         reason: 'invalid'
     }
  ] 

Is there an other way to use enum in json ?

Eleftheria-99 commented 2 years ago

I found a solution, it needs an enum , therefore you put 1 or 2 as number, 1 is the value for TEXT, 2 is the value for EXPIRY_NOTIFICATION

ncalteen commented 2 years ago

Hello,

Your solution is correct. Alternatively, you can set messageType as the enum value directly.

{
  "messageType": "EXPIRATION_NOTIFICATION"
}

I apologize, but this repository is being archived and replaced by google-pay/wallet-samples going forward. If you still have a question, please open a new issue in that repository.

Thank you!