I’m trying to create a webhook that will run a simple JavaScript
file when called. I’ve followed the tutorial and I’m able to create the webhook with the file attached. I’ve also tested the JavaScript
in a simple HTML
file and it works fine. However, then I call the webhook, the JavaScript
file is never fired.
I maybe misunderstanding how the associated of a file with a webhook works. I was making the assumption from the Librato example where a JSON
file is uploaded and associated with a webhook.
My objective is to create a new object in Parse.com when the webhook is called.
Here is the JavaScript file I’m using:
Parse.initialize("XXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXX");
var GameScore = Parse.Object.extend("GameScore");
var gameScore = new GameScore();
gameScore.set("score", 1337);
gameScore.set("playerName", "Sean Plott");
gameScore.set("cheatMode", false);
gameScore.save(null, {
success: function(gameScore) {
// Execute any logic that should take place after the object is saved.
alert('New object created with objectId: ' + gameScore.id);
},
error: function(gameScore, error) {
// Execute any logic that should take place if the save fails.
// error is a Parse.Error with an error code and message.
alert('Failed to create new object, with error code: ' + error.message);
}
});
My SparkCore code:
#define publish_delay 10000
unsigned int lastPublish = 0;
void setup() {
}
void loop() {
unsigned long now = millis();
if ((now - lastPublish) < publish_delay) {
// it hasn't been 10 seconds yet...
return;
}
Spark.publish("ParsePost");
}
EDIT:
Here is what I get when I call
spark webhook list
When I created my webhook:
I’ve edited your post to properly format the code. Please check out this post, so you know how to do this yourself in the future. Thanks in advance! ~Jordy