question

jgonzrodr avatar image
jgonzrodr asked

InvalidData, Looking for something?

Hello, I'm trying to send a test message to a registered device, but I'm receiving a InvalidData response. The following is the sended message: POST /messaging/registrations/{THE REGISTRATION ID}/messages HTTP/1.1 Host: api.amazon.com Authorization: Bearer {THE ACCESS TOKEN} Content-Type: application/json X-Amzn-Type-Version: com.amazon.device.messaging.ADMMessage@1.0 Accept: application/json X-Amzn-Accept-Type: com.amazon.device.messaging.ADMSendResult@1.0 { "data":{"message":"Prueba amazon"}, "expiresAfter":86400 } This is the response: HTTP/1.1 400 Bad Request Date: Wed, 08 Oct 2014 11:37:22 GMT Server: Server x-amzn-RequestId: 77e6df3a-4edf-11e4-b2c0-cf6def6aa297 Content-Type: application/json Content-Length: 40 Vary: User-Agent Cneonction: close {"message":null,"reason":"InvalidData"}

Looking for Something?

We're sorry. The Web address you entered is not a functioning page on our site. Please double-check the URL for typos and other errors. Or go to our home page.

Vous recherchez quelque chose?

Nous sommes désolés. L'adresse Web que vous avez entrée n'est pas fonctionnelle. Vérifiez bien le lien URL ou allez à notre page d'accueil.

However, if I collapse the JSON message in this way: POST /messaging/registrations/{THE REGISTRATION ID}/messages HTTP/1.1 Host: api.amazon.com Authorization: Bearer {THE ACCESS TOKEN} Content-Type: application/json X-Amzn-Type-Version: com.amazon.device.messaging.ADMMessage@1.0 Accept: application/json X-Amzn-Accept-Type: com.amazon.device.messaging.ADMSendResult@1.0 {"data":{"message":"Prueba amazon"}, "expiresAfter":86400} Then I get the following message: HTTP/1.1 400 Bad Request Date: Wed, 08 Oct 2014 11:46:23 GMT Server: Server x-amzn-RequestId: babbd466-4ee0-11e4-94c3-8d9f10164d8a Content-Type: application/json Content-Length: 40 Vary: User-Agent Cneonction: close {"message":null,"reason":"InvalidData"} HTTP/1.1 400 Bad Request Date: Wed, 08 Oct 2014 11:46:24 GMT Server: Server Content-Length: 11 Connection: close Content-Type: text/html; charset=iso-8859-1 Bad Request What is the failure in the sended message? Thanks Jose Gonzalez-Rodriguez
amazon device messaging
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
From your message it's being hard to understand the issue. Can you please share the code that prepares the HTTP request for sending the message?
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

jgonzrodr avatar image
jgonzrodr answered
Hello. I'm sorry for the format of the previus message. The source code that prepares the HTTP request is shared between several files. The resulting HTTP request is: POST /messaging/registrations/{REGISTRATION_ID}/messages HTTP/1.1 Host: api.amazon.com Authorization: Bearer {ACCESS_TOKEN} Content-Type: application/json X-Amzn-Type-Version: com.amazon.device.messaging.ADMMessage@1.0 Accept: application/json X-Amzn-Accept-Type: com.amazon.device.messaging.ADMSendResult@1.0 {"data":{"from":"CAJAMAR","message":"Prueba amazon"},"consolidationKey":"ADM_Enqueue_Sample","expiresAfter":86400} We send it creating a socket from a SSLSocketFactory. I hope that this can help. Best regards, Jose.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Using SSLSocketFactory is not recommended according to our sample guide shown in below link https://developer.amazon.com/public/apis/engage/device-messaging/tech-docs/06-sending-a-message#Making%20the%20Message%20Request%20and%20Handling%20the%20Response You should use HttpsURLConnection class of javax.net.ssl package without setting a SSLSocketFactory instance there explicitly as guided in the link.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.