New Feature! Webhooks!

checking now…

edit: just tested this and it seems to be working @voodootikigod are you still seeing this? Can you PM me details on what you’re seeing / trying to create?

Thanks,
David

Hey All!

Just wanted to share an enhancement I added recently, custom templated variables in your hooks!

http://docs.spark.io/webhooks/#templates-custom-template-variables

Thanks!
David

2 Likes

Is it possible to reverse the direction of webhooks so that after a Spark Core has connected to a private cloud server, that same cloud could initiate communication to the Spark Core? Basically what I want to be able to do is to be able to have a user of my device/service initiate something from a web interface running on the cloud, say setting some configuration value that needs to change on a Spark Core, and then have the cloud server push that value to the Spark Core without the Spark Core needing to poll for updates. If it’s not possible with Webhooks, can someone make a recommendation?

You can publish to an event that the core is subscribed to without polling

1 Like

I can do this completely from separate cloud code? I know I can do this from the Spark Core side, but how about from my own cloud code?

I think you mean can you publish events into the cloud via the API, and the answer is yes!

(scroll down to “Publishing events”)
http://docs.spark.io/api/#reading-data-from-a-core-events

or you can use “publishEvent” from spark-js

Thanks,
David

1 Like

Well sort of, I’m evaluating writing my own cloud event system versus being able to use the one that Spark provides. It hasn’t been clear to me what’s possible on the event side, but I might have missed reading this section in the docs. I appreciate the reply.

Yes I most definitely missed this section and that should work out nicely. Thanks very much for pointing me to it!

Hello everyone.

I’m trying to create webhook since 3 days. But i can’t reach anything.

Firstly i have created a text file named with login.json which contains json data on Desktop, and run cmd window. I run command in terminal then i have changed my file directory to Desktop with cd Desktop command. After that i run command which is particle webhook create login.json. But i got a message Please specify an event name. What’s wrong with?

1 Like

Would you mind posting the contents of the JSON file? That should make it easier to spot any potential issues.

Yes. but i can’t create webhook from text file.

Which is why I’m asking you to post the contents of that file here :wink:

1 Like

I want to post JSON file

At this point I think it would be a wise decision to go over the documentation once more, and try do execute the example in there. That should give you a basic idea of what you're supposed to be doing.
This is also a good topic to get going with webhooks relatively easy:

Ok thanks for your reply. I can create JSON file. And i must get response from post. How can i get it?

Again, this is mentioned in the docs: http://docs.particle.io/photon/webhooks/#handling-web-responses please do take a look, and read the whole page. That should give you more insight as to what’s going on.
There are also quite a few topics about this on the forum. Please try the search functionality, and I’m sure multiple topics will pop up. Here’s a useful one to get you started:
Cloud JSON Parsing

1 Like

Hi @emrebekar67,

He’s asking you to copy-paste the file into this thread on the forums, so we can see what configuration you’re specifying for the hook, and so we can fix any errors.

Thanks,
David

3 Likes

I have created a json file at below.

{
    "eventName": "rest_login2",
    "url": "https://login.salesforce.com/services/Soap/u/33.0",
    "requestType": "POST",
	"headers": {
		"Content-Type":	"text/xml; charset=UTF-8",
		"SOAPAction": "login",
		"Accept": "text/xml"
	}	
}

request type is shown as undefined. What is wrong?

Using settings from the file emre.json
Sending webhook request { uri: 'https://api.particle.io/v1/webhooks',
method: 'POST',
json: true,
form:
{ eventName: 'rest_login2',
url: 'https://login.salesforce.com/services/Soap/u/33.0',
requestType: undefined,
headers:
{ 'Content-Type': 'text/xml; charset=UTF-8',
SOAPAction: 'login',
Accept: 'text/xml' },
event: 'rest_login2',
deviceid: undefined,
access_token: 'ecb70f15232ea2e6c99dc6022b47678168760235' } }
Successfully created webhook!

Hi @emrebekar67,

Looks like the CLI might not be behaving quite correctly here. I just opened up a bug for this here:

Thanks,
David