Anyone getting JSON errors with CURL notification testing? PLZ help!


My name is Esteban and I need your help please.

I am developing an app in ionic for a while and now i am currently implementing notifications.

The problem is that when a test the notifications in debug mode with a CURL request i get the following error:

{"error": {"message": "Invalid Content-Type header value: 'application/x-www-form-urlencoded'. Supported media type(s) are: 'application/json'.", "type": "UnsupportedMediaType", "link": null}, "meta": {"request_id": "f2404220-bcb8-4d46-be20-cb671804b6e8", "version": "2.0.0-beta.0", "status": 415}

the CURL is this:

    curl -X POST -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI666666666666666666FjLTRiZGItYjJjMC0yNWE2ZTNmNmE0YzcifQ.64U46Sfw4S9bmqz0GLpqaV-DUHJcGwoOD7oZiAgSfYI" -d '{
         "tokens": ["DEV-92fa0230-6359-4ea9-a82f-bb0247a3ea43"],
         "profile": "fake_push_profile",
         "notification": {
             "message": "Hello World!"
     }' ""

I tested the connection with the ionics servers with this and everything is ok:

curl -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJmY666666666666666ZGItYjJjMC0yNWE2ZTNmNmE0YzcifQ.64U46Sfw4S9bmqz0GLpqaV-DUHJcGwoOD7oZiAgSfYI"

If you can help me i will be very grateful.


You should probably edit that post to redact the bearer tokens.

I changed a bit, ty!

Hey there! If you’re having errors with push, please contact the support

Same issue :frowning:
I’m on it for 30 minutes now…

Having the same problem, any clue?

Hi, I figured Out, you need to add json header, like this:

curl -X POST -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI3NTc4YjZjYi02ZTgxLTQ0Y2MtOTcyYi0zY2NhODkzMWZmYjgifQ.VATH0-cD-lmMCXNqP-30ijGCs8RMXR5zZZZZZXXXXX" -H "Content-Type: application/json" -d '{
    "tokens": ["DEV-592505d8-15ed-4156-aec4-XXXXXXX"],
    "profile": "fake_push_profile",
    "notification": {
        "message": "Hello World!"
}' ""

Maybe, you’ll need to create a profile, inside your app.

Now, I received a state “enqueued”, but the notification doesn’t appear. Should I see the notification inside IonicView? I had the app opened.

Thank you.

1 Like