Search code examples
azurenotificationsazureservicebusservicebusazure-notificationhub

Azure Notification Hub: The supplied notification payload is invalid


I'm trying to send a JSON notification to APNS and when I try to send it I'm getting 400 Bad Request with the error message:

The supplied notification payload is invalid.

Here is my Notification JSON:

{"uri":"myApp://test","type":"test_push","badge":1,"content-available":1}

I create the notification like this:

notif = new AppleNotification(json);

I'm sending the notification:

client.SendNotificationAsync(notif, "myTag")

After that, I'm getting the error. The content type is application/xml by default, after I got the error, I've started setting the content type to application/json but nothing changed.

What am I doing wrong?

UPDATE: My hub and certificates are installed correctly; I can send a successful test notification through Azure Portal.


Solution

  • Can,

    Your payload is malformed, please try with the following:

    {"aps":{"uri":"myApp://test","type":"test_push","badge":1,"content-available":1}}