I’m trying to call a cloud code endpoint that I created in Parse using a Spark webhook
. I’m working off the LIBRATO example in the Spark docs and I’m able to get that working fine.
Parse gives an exmaple of how to call the endpoint with a curl
command like this:
curl -X POST \
-H "X-Parse-Application-Id: MYAPPLICATIONID" \
-H "X-Parse-REST-API-Key: MYRESTAPPLICATIONID" \
-H "Content-Type: application/json" \
-d '{}' \
https://api.parse.com/1/functions/hello
Which calling this through curl
does product the desired result.
I’ve tried to adapt that to the JSON from the LIBRATO example so I end up with this.
{
"eventName": "buttonSelected_",
"url": "https://api.parse.com/1/functions/hello",
"requestType": "POST",
"Content-Type": "application/json",
"Headers": {
"X-Parse-Application-Id": "MYAPPLICATIONID",
"X-Parse-REST-API-Key": "MYAPPLICATIONRESTID"
},
"json": {},
"mydevices": true
}
…which doesn’t work. Nothing happens on the Parse side.
I’ve also tried moving the Parse key fields outside of the “Headers”.
{
"eventName": "buttonSelected_",
"url": "https://api.parse.com/1/functions/hello",
"requestType": "POST",
"Content-Type": "application/json",
"X-Parse-Application-Id": "MYAPPLICATIONID",
"X-Parse-REST-API-Key": "MYAPPLICATIONRESTID",
"json": {},
"mydevices": true
}
When I do this and try to upload the JSON through
spark webhook create JSONTest.json
I get the error:
tryParse error [SyntaxError: Unexpected string]
Using settings from the file JSONTest.json
Please specify an event name
So I assume the format of the JSON is wrong.
I’m am going crazy trying trying to figure this out because it seems like it should be extremely easy to implement! I’m assuming that my problem is how to pass along the credentials in the JSON post up to Parse but not sure what I’m doing wrong.