Search code examples
push-notificationibm-mobilefirstbulk

Bulk Send Message not working in MobileFirst Platform


I am trying to use the Bulk Send Message API in IBM MobileFirst Platform Foundation 7.0. Unfortunately, the example JSON from the docs does not work and gets an error about the object structure being sent.

This is the JSON Object I'm sending:

{
"//ArrayOfMessageBody": [
    {
        "messages": {
            "alert": "Test message"
        },
        "settings": {
            "apns": {
                "actionKey": "Ok"
            }
        },
        "target": {
            "consumerIds": [
                "MyConsumerId1"
            ],
            "deviceIds": [
                "MyDeviceId1"
            ],
            "platforms": [
                "A"
            ]
        }
    }
]

}

And Here is the server's response error:

com.ibm.json.java.JSONObject cannot be cast to com.ibm.json.java.JSONArray

I am having success sending to devices via the single Send Message API, so I know messaging works. However, Bulk Send Message is failing.


Solution

  • It turns out that the documentation was what hung me up. If you send an array of messages to the bulk send message endpoint it will work.

    [{message1}, {message2}, ...]
    

    I'm still not sure what the whole //ArrayOfMessageBody thing is.