question

Alexander Farber avatar image
Alexander Farber asked

ADM send message response {"Message":null}

Hello, I am using the following Java code to send ADM push notifications with the help of Jetty HTTP client:

// this string is POSTed to ADM server
public String toAdmBody() {
    Map<String, Object> root = new HashMap<>();
    Map<String, String> data = new HashMap<>();
    root.put("data", data);
    data.put("body", "Alexander: test 42");
    // ADM does not accept integers for some reason
    data.put("gid", String.valueOf(42));
    return JSON.toString(root);
}

private void postMessage(String registrationId, int uid, String jsonStr) {
    mHttpClient.POST(String.format("https://api.amazon.com/messaging/registrations/%1$s/messages", registrationId))
        .header(HttpHeader.ACCEPT, "application/json")
        .header(HttpHeader.CONTENT_TYPE, "application/json")
        .header(HttpHeader.AUTHORIZATION, "Bearer " + mAccessToken)
        .header("X-Amzn-Type-Version", "com.amazon.device.messaging.ADMMessage@1.0")
        .header("X-Amzn-Accept-Type", "com.amazon.device.messaging.ADMSendResult@1.0")
        // add registrationID and notification body - for retrying after fetching token
        .attribute("registrationId", registrationId)
        .attribute("body", jsonStr)
        .content(new StringContentProvider(jsonStr))
        .send(mMessageListener);
}

And while the code worked for me every time in February, returning ADM backend responses like the following one -

adm message success (200): {"registrationID":"amzn1.adm-registration.v3.Y29tLmFtYXpvbi5EZXZpY2VNZXNzYWdpbmcuUmVnaXN0cmF0aW9uSWRFbmNyeXB0aW9uS2V5ITEhdTIvVDJrSXpiVU0waVhHcGNKY3A0Vi9Qa3Z0MWVIUjlEY1VhRXJ3dVNFY01STUxwUm54b1FwR21yL3Rhd1AyQXZIMGd5Mm1IU28yQjZ2WjNGZGxBVnI0WW1TTkw2eGdoL3pKYjdxcUVlUUpuaitMeXZpblJlVnpFNURQa0xxN0FmV3hObDBXdmw1WW5Va3J4RDRRZ3ladUgvQmFhOTBLekRlMWxrSUlSQ2xTWFlrM1ZzdGFxQzZQa05EYkUwSzJSUFV3d3RWM3pVNTVDNnZ6QnlDZzVoR2pJTHJpaGR2SVpnZjdmcHQ5TWtwaE1rdGI4dTRrT2dxcm91eVNIT2pDMUNjTTNhTW9UOHRxei9FRU50eEM4NHRNN2R6bDVsazRacmF0TzAxei9zSnQ0cTgwMW9DM0NkV3paM2h4cHAycWk3d0tKNFl0cVZZY21RUEFuYVNqRDJ3PT0hZmlTRzdMMHRJOEdqQTlVTXlWQ2Z4UT09"}

It has stopped working now and I keep getting (here you see more of my logs, including fetching the access token)

adm postMessage: 1185 <- {"data":{"gid":"691","body":"Alexander: test 4"}}
adm postToken: remaining tries=3 url=https://api.amazon.com/auth/O2/token body=grant_type=client_credentials&scope=messaging:push&client_id=amzn1.application-oa2-client.b387f1af3ffe490ca3657e9b07b79bea&client_secret=05xxxxxxxxxx026
adm token success: {"access_token":"Atc|MQEBINxiq6HtYYEgZK3GfXqFoLi0zGTBv_04srjVb6sugTzxdFkuawi-DuOxd-p-8oA3mWp4Xm5BXXfsCTFGhjZMzR8C7PxAOi34XmPSsqIDD20m961HI5K8zV6Szu5E_buzkykvEdt_QmPmAPvEaB1Cg_qr6mjrqA8hRX71UeQjoZkxV3gkKXb6BIDgFxaIhBuuUK5pP-H_s5tdkaRT4G_e1OS7x-Hr_emLw3kIrR8q7jygPx9og8eVwYJ6NZ4sZ4br0E1djC9rtKdeo0Nf51BjRbS_3wH70zINfIfMEK8PKitw7A","scope":"messaging:push","token_type":"bearer","expires_in":3600}
adm message success (200): {"Message":null}

My app is published at https://www.amazon.com/Alexander-Farber-Slova-Farbera/dp/B0792GQQZR

Please help

amazon device messagingnotifications
1 comment
10 |5000

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

Looking into it...

0 Likes 0 ·

1 Answer

Levon@Amazon avatar image
Levon@Amazon answered

Hi Alexander,

ADM is supposed to either send 200 with a registration ID, or error code with a reason:
https://developer.amazon.com/docs/adm/send-message.html#response-format

Can you please provide us with the ADM registrationId and time range where you send a message to this registration Id and get 200 response with {"Message":null}? If you'd rather not post that info on this public forum, then login to your Dev Portal account, use the "Contact Us" form, and provide that additional info, along with your app name / ID, and the URL to this forum post for context, and we will investigate. Thanks!

10 |5000

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