3

I'm using Urban Airship and testing using their REST API. I have Google Cloud Messaging connected to the Urban Airship account, and one Android device registered successfully.
I can successfully send test messages from the the interface on the Urban Airship dashboard.

But when I try using the REST API https://go.urbanairship.com/api/push/ with the body

{
 "audience" :  "all" ,
 "device_types" : "all",
 "notification" : {
   "android": {
     "alert" : "This is a broadcast."
   }
 }
}

I get a 400 Bad Request response with This app is not configured for iOS push

Any idea why?

UPDATE: Listing the specific device APID in the "audience" section returns the same result

Ron Harlev
  • 16,227
  • 24
  • 89
  • 132
  • I don't know the API, but it seems like you should specify something like "android" instead of "all" in "device_types" (assuming you only want to push to an Android app). – Eran Sep 03 '13 at 22:13
  • This issue still open, but I managed to send push messages with UrbanBlimp https://github.com/SimonCropp/UrbanBlimp – Ron Harlev Sep 03 '13 at 22:55

1 Answers1

5

What you have is correct, however you need to include the following HTTP header:

Accept: "application/vnd.urbanairship+json; version=3;

For beginner Ruby developers, it can be achieved like this:

req = Net::HTTP::Post.new(uri.path)
req["Accept"] = "application/vnd.urbanairship+json; version=3;"

When, e.g., posting a notification to UrbanAirship.

igordc
  • 1,525
  • 1
  • 14
  • 20
  • Adding the `accept` header made it work for me with `device_types: "all"`. Wish it was in the docs, UA. – Andy V Feb 20 '14 at 02:54