I have a problem: I want to publish an event from an external source to the particle cloud. When I try it with the following website, all works great: http://onlinecurl.com/
curl --data name=myevent --data data=Hello World --data
But I need now the URL to make a POST request. I tried this URL but it always caused an error:
I replaced my token with xxxx!
Could you say me what I made wrong?
I am not sure I understand your problem fully but I will try to add some information.
POST HTTP calls do not typically have URL parameters (the
name=myevent?access_token=XXX part in your second URL). That is why the doc says to do this:
$ curl https://api.particle.io/v1/devices/events \
-d "name=myevent" \
-d "data=Hello World" \
-d "private=true" \
-d "ttl=60" \
This uses a URL with just the events path but adds parameters using -d for all the other required elements. These parameters are passed in the body of the POST request and not in the URL. This is one of the primary differences between POST and GET requests over HTTP.
Ok , my problem is that a website should send something to my electron but the electron doesn’t have a static ip so my idea was that I use the cloud so that the electron can receive the data. Any other ideas?
OK so using publish to send stuff to your device works well–you just can’t use a GET URL to publish, you have to POST. Not only does your electron have a non-static IP address, it is on a cellular network that is not routed the same way as an ethernet or WiFi network so outbound TCP connections are fine, but inbound is a no-no.
What code on the website are you using to send the publish? NodeJS? PHP? Python? Curl? Something else? That is the part you are missing.
I am assuming you control and code the website but if not, then is this something a webhook could be used for? Having the Particle Cloud act as the intermediary works well too.
I don’t control the website, it’s paypal.com
Paypal transmits the IPN message to a website. At the end the Electron should get this message
OK you need a host on the Internet to translate the paypal IPN messages to Particle messages.
You might be able to get that host on the Internet to be the Particle Cloud using a webhook.
Or you could have your own host on the Internet doing the translation by running a simple web service.
So how can I use a webhook to receive the data and send it to my Electron?
I thought a webhook can only send data to another website?
Now I get a success message from the PayPal IPN simulator but I cannot see the date in the webhook:
I use this URL:
I have to use “test” because otherwise I get an error. Any ideas how I can see the data?
This is an example of the data which PayPal sends to me:
@peekay123, a webhook response is limited to 512 bytes per response message. A longer website response will create two or more subscription responses so you may need to accommodate for that. Have you looked at the total response payload size from paypas?
I tried with less data (with https://www.hurl.it/) but no success
@electronweather, again, what is the total size the data returned? What format are you expecting - XML, JSON, other?
Idk exactly, i only get this information: application/x-www-form-urlencoded
content-lenght: around 900
The problem is that the data doesnt show up (because I had to use “test” which creates a “test-event” but I wasn’t able to add some custom data
@electronweather, if the “test” payload is 900 bytes then when you do get the data in there, you can expect at least two subscribe messages back to your device. As for getting the right message/data together, I will need to defer to @bko.
Ok, thank you for your help
The test message is from particle:
I think it’s only a few bytes
I guess I have come around to think that you do in fact want to have your own server talking to paypal on the one side and the particle cloud on the other.
As I understand the API, you can view the payment data and basically say “yes” or “no” to the transaction. I think you should set up your own server that abstracts the data (do you really need all that data on the Electron?) and then lets you say “yes” or “no” from the Electron back to your server, which would then give the final answer to paypal.
That is the direction I would recommend.
Isn’t it possible to send the data directly to the Electron?
If it’s possible, I would like to use only the Particle Cloud and the electron