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


#1

Hi,

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!"
         }
     }' "https://api.ionic.io/push/notifications"

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

curl -X GET -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJmY666666666666666ZGItYjJjMC0yNWE2ZTNmNmE0YzcifQ.64U46Sfw4S9bmqz0GLpqaV-DUHJcGwoOD7oZiAgSfYI" https://api.ionic.io/auth/test

If you can help me i will be very grateful.

Thanks!


#2

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


#3

I changed a bit, ty!


#4

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


#5

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


#6

Having the same problem, any clue?


#7

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!"
    }
}' "https://api.ionic.io/push/notifications"

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.