0

I have used the updated Journey builder SDK for Android. The device has been registered. I tried to send the API triggered push using the following REST API,

Host: https://www.exacttargetapis.com
POST /push/v1/messageContact/OEl8ODow/send 
Content-Type: application/json
Authorization: Bearer YOUR_ACCESS_TOKEN

My code:

public static final String url = "https://www.exacttargetapis.com/push/v1/messageContact/" + PUSH_MESSAGE_ID + "/send ";
    try {
            URL url1 = new URL(url);
            conn = (HttpURLConnection) url1.openConnection();
            conn.setRequestMethod("POST");
            conn.setDoInput(true);
            conn.setDoOutput(true);
            conn.setRequestProperty("Content-Type", "application/json");
            conn.setRequestProperty("Authorization", "Bearer " + accessTokenForCompaign); 
            DataOutputStream wr = new DataOutputStream(conn.getOutputStream());  
            try {   
                String req="{\n" +
                        "    \"DeviceTokens\": [\n" +
                        "\"" + appData.getDeviceId() + "\"" +
                       "\n" +
                        "    ],\n" +
                        "  \n" +
                        "    \"Override\": true,\n" +
                        "    \"MessageText\": \"Dear "
                        + userName +
                        " your information has been submitted successfully!\"\n" +
                        "   \n" +
                        "}";
                Log.e("JSON Input", req);
                wr.writeBytes(req);
                wr.flush();
                wr.close();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            conn.connect();
            conn.connect();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return conn;

My request as follows,

{
  "DeviceTokens": [
        "C3816D87C06FAFBA969CF3398BBAF960DF308658DFF10E818CD16239FFDDAFA9"
    ],
    "Override": true,
    "MessageText": "Dear qwerty asdf your information has been submitted successfully!"
}

The response I got, and the response code is 202. And the push is not received to the mobile.

 {"tokenId":"65fc5215-3a0b-4761-b76e-c9a0f8198651"}
1
  • My mistake. Instead of device token, I'm using device Id in the request. Giving the device token works fine.
    – Manikandan
    Commented Nov 7, 2017 at 6:51

1 Answer 1

1

Logging on the device, if the message is being received, would be a great place to start.

You can also look at Troubleshooting Push which provides a curl statement to test your setup without going through the Marketing Cloud Servers:

#!/usr/bin/env bash
# REPLACE
# LEGACY_SERVER_KEY with your Push API key from Google
# DEVICE_TOKEN with the push token for your device
# ALERT_TEXT with the text of your message
curl --header "Authorization: key=LEGACY_SERVER_KEY" --header Content-Type:"application/json" https://gcm-http.googleapis.com/gcm/send -d "{\"to\":\"DEVICE_TOKEN\",\"data\":{\"_m\":\"MDoxMTQ6MA\",\"alert\":\"ALERT_TEXT\"}}"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .