Aiman
Aiman

Reputation: 63

Unable to push notification using parse

I try trigger below script and send notification to mobile using parse. Below is my script.

curl -X POST \
  -H "X-Parse-Application-Id:app-id-here" \
  -H "X-Parse-REST-API-Key:rest-key-here" \
  -H "Content-Type: application/json" \
  -d '{ "data": {"alert": "A test notification from Parse!"}}' \
  https://api.parse.com/1/push

and i got error as below:

curl: (6) Could not resolve host: \ {"code":107,"error":"invalid json: { data: {alert:A"}

whats wrong with my json data?

Upvotes: 0

Views: 1294

Answers (1)

Fosco
Fosco

Reputation: 38506

So the main issue is that the 'script' needs to be on multiple lines if the backslash marks (\) are present, and there cannot be any spaces after backslashes. I've edited your question to format it correctly, and it works.. returning a better error.

{"code":115,"error":"Missing the push channels."}

You just need to alter the JSON to include a channel or a query to push to, based on the docs here: https://parse.com/docs/push_guide#sending-channels/REST

curl -X POST \
  -H "X-Parse-Application-Id:app-id-here" \
  -H "X-Parse-REST-API-Key:rest-key-here" \
  -H "Content-Type: application/json" \
  -d '{ "channels": ["Giants"], "data": {"alert": "A test notification from Parse!"}}' \
  https://api.parse.com/1/push

Upvotes: 1

Related Questions