# Event problem :(

**URL:** <https://community.particle.io/t/event-problem/38522>\
**Category:** Troubleshooting\
**Created:** [January 5, 2018, 3:55pm UTC](https://community.particle.io/t/event-problem/38522 "2018-01-05T15:55:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 3:55pm UTC](https://community.particle.io/t/event-problem/38522/1 "2018-01-05T15:55:18Z")

</div>

Hi 🙂

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/](http://onlinecurl.com/)

Code:

curl --data name=myevent --data data=Hello World --data  
access\_token=xxxx  
[https://api.particle.io/v1/devices/events](https://api.particle.io/v1/devices/events)

But I need now the URL to make a POST request. I tried this URL but it always caused an error:

[https://api.particle.io/v1/devices/events/name=myevent?access\_token=xxxx](https://api.particle.io/v1/devices/events/name=myevent?access_token=xxxx)  
([https://www.hurl.it/](https://www.hurl.it/))

I replaced my token with xxxx!

Could you say me what I made wrong?

best regards

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [January 5, 2018, 4:00pm UTC](https://community.particle.io/t/event-problem/38522/2 "2018-01-05T16:00:22Z")

</div>

@electronweather, did you review the docs?

[https://docs.particle.io/reference/api/](https://docs.particle.io/reference/api/)

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 4:03pm UTC](https://community.particle.io/t/event-problem/38522/3 "2018-01-05T16:03:27Z")

</div>

yes @peekay123

[https://docs.particle.io/reference/api/#events](https://docs.particle.io/reference/api/#events)

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 5:40pm UTC](https://community.particle.io/t/event-problem/38522/4 "2018-01-05T17:40:38Z")

</div>

any solution?

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [January 5, 2018, 5:45pm UTC](https://community.particle.io/t/event-problem/38522/5 "2018-01-05T17:45:05Z")

</div>

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:

```auto
$ curl https://api.particle.io/v1/devices/events \
       -d "name=myevent" \
       -d "data=Hello World" \
       -d "private=true" \
       -d "ttl=60" \
       -d "access_token=1234"

```

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.

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 5:50pm UTC](https://community.particle.io/t/event-problem/38522/6 "2018-01-05T17:50:23Z")

</div>

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?

@bko

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [January 5, 2018, 5:57pm UTC](https://community.particle.io/t/event-problem/38522/7 "2018-01-05T17:57:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 6:04pm UTC](https://community.particle.io/t/event-problem/38522/8 "2018-01-05T18:04:08Z")

</div>

I don’t control the website, it’s [paypal.com](http://paypal.com) 😅  
Paypal transmits the IPN message to a website. At the end the Electron should get this message

@bko

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [January 5, 2018, 6:09pm UTC](https://community.particle.io/t/event-problem/38522/9 "2018-01-05T18:09:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 6:10pm UTC](https://community.particle.io/t/event-problem/38522/10 "2018-01-05T18:10:53Z")

</div>

[https://picload.org/view/ddoogrgl/paypal.jpg.html](https://picload.org/view/ddoogrgl/paypal.jpg.html)

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?

@bko

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 7:37pm UTC](https://community.particle.io/t/event-problem/38522/11 "2018-01-05T19:37:38Z")

</div>

Now I get a success message from the PayPal IPN simulator but I cannot see the date in the webhook:

[https://picload.org/view/ddoorgil/paypal1.jpg.html](https://picload.org/view/ddoorgil/paypal1.jpg.html)

I use this URL:

[https://api.particle.io/v1/integrations/5a4f7b97d67baa4522044dc9/test?access\_token=xxxxx](https://api.particle.io/v1/integrations/5a4f7b97d67baa4522044dc9/test?access_token=xxxxx)

I have to use “test” because otherwise I get an error. Any ideas how I can see the data?

@bko

This is an example of the data which PayPal sends to me:

payment\_type=echeck&payment\_date=Fri%20Jan%2005%202018%2019%3A56%3A14%20GMT%2B0100&payment\_status=Completed&address\_status=confirmed&payer\_status=verified&first\_name=John&last\_name=Smith&payer\_email=buyer@paypalsandbox.com&payer\_id=TESTBUYERID01&address\_name=John%20Smith&address\_country=United%20States&address\_country\_code=US&address\_zip=95131&address\_state=CA&address\_city=San%20Jose&address\_street=123%20any%20street&business=seller@paypalsandbox.com&receiver\_email=seller@paypalsandbox.com&receiver\_id=seller@paypalsandbox.com&residence\_country=US&item\_name=something&item\_number=AK-1234&quantity=1&shipping=3.04&tax=2.02&mc\_currency=USD&mc\_fee=0.44&mc\_gross=12.34&mc\_gross\_1=12.34&txn\_type=web\_accept&txn\_id=448789463&notify\_version=2.1&custom=xyz123&invoice=abc1234&test\_ipn=1&verify\_sign=AzFmRN2alSXsVcRQ-bkJDjsW0iFTAzylZCsnqZ.VFNwA6TyQlnbux0ho

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [January 5, 2018, 8:09pm UTC](https://community.particle.io/t/event-problem/38522/12 "2018-01-05T20:09:03Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 8:12pm UTC](https://community.particle.io/t/event-problem/38522/13 "2018-01-05T20:12:09Z")

</div>

I tried with less data (with [https://www.hurl.it/](https://www.hurl.it/)) but no success ☹

@peekay123

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [January 5, 2018, 8:16pm UTC](https://community.particle.io/t/event-problem/38522/14 "2018-01-05T20:16:56Z")

</div>

@electronweather, again, what is the total size the data returned? What format are you expecting - XML, JSON, other?

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 8:19pm UTC](https://community.particle.io/t/event-problem/38522/15 "2018-01-05T20:19:44Z")

</div>

Idk exactly, i only get this information: application/x-www-form-urlencoded  
content-lenght: around 900

@peekay123

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 8:23pm UTC](https://community.particle.io/t/event-problem/38522/16 "2018-01-05T20:23:31Z")

</div>

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 ☹

@peekay123

---

<div class="post-metadata">

**Author:** ![peekay123](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/peekay123/32/810_2.png) [@peekay123](https://community.particle.io/u/peekay123)\
**Post date:** [January 5, 2018, 8:27pm UTC](https://community.particle.io/t/event-problem/38522/17 "2018-01-05T20:27:46Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 8:33pm UTC](https://community.particle.io/t/event-problem/38522/18 "2018-01-05T20:33:41Z")

</div>

Ok, thank you for your help 🙂

The test message is from particle:

/5a4f7b97d67baa4522044dc9/test?access\_token=xxxxx

I think it’s only a few bytes

@bko @peekay123

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [January 5, 2018, 8:45pm UTC](https://community.particle.io/t/event-problem/38522/19 "2018-01-05T20:45:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![electronweather](https://avatars.discourse-cdn.com/v4/letter/e/e95f7d/32.png) [@electronweather](https://community.particle.io/u/electronweather)\
**Post date:** [January 5, 2018, 8:54pm UTC](https://community.particle.io/t/event-problem/38522/20 "2018-01-05T20:54:37Z")

</div>

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

@bko
