[API] Publishing product event not working

Hey all,

I’m working on a project that requires a request being sent to my computer and then a program generating and sending a response back to the particle. The method that I’m using is the publishing product event method. However, when I try to publish this event, I get an error saying ‘product not found’. I find this strange because I’m pulling the product ID directly from the initial request, so it should be working just fine. I can print out the initial request and the variable that holds the ID and the IDs are both identical.

What could be causing this issue? The electron is connected to the cloud for the entirety of the request, so I don’t think it’s an issue of losing connection. Is there a different way I should be calling this function?

Please let me know if there’s any more information I can provide that would help diagnose the problem. Thanks in advance.

Product events are one-way from device to cloud. A device cannot receive product events. The only way to send a private event to a device is using customer impersonation tokens.

However, I’m not entirely sure that’s the problem you’re seeing because that’s not the error you should be seeing. Since this involves various private-ish things like product and device IDs, the best option is probably to create a support ticket to work through this.


Gotcha, will do. Would rewriting my program to send the particle my data through an event it’s subscribed to work?

The issue is that when you subscribe to an event on a device, you can either set it to MY_DEVICES (only private events) or not (only public events).

Public events (not using MY_DEVICES and sent using PUBLIC) can be received in this case, however that also means anyone can see the event, and anyone can generate such an event. This probably isn’t what you want.

Private events (using MY_DEVICES and PRIVATE) are generally a better idea, however you can’t send a private event to a product device using a product bearer token. You can only send a private event to a device using the device owner’s impersonation token.

That’s because MY_DEVICES means that the owner sent it (or a product impersonating the user sent it). There’s no equivalent MY_PRODUCT because product events are currently only one-way from device to product, not product to device.

For Electron products, many product creators get around the by claiming all devices to a single account. Thus you can have one user token that can send to all devices.