I’m working on a workshop where we connect a couple of photons to SAP HCP (HANA Cloud Platform).
At first I tried this all with a Core. After some digging into this community I got it to work. But then I needed to buy a couple of new boards and the Core’s were not available anymore, so I moved to Photon’s. No issue so far One Photon is working fine with the DHT11.
So what did I do…
bought 8 Photon’s, 8 DHT11’s a couple of wires and resistors. Let’s get the party started!
Registered all the photon’s on one user ID
Created the code (please don’t judge my lack of coding)
But then i ran into a tiny little issue. 4 Users are working on 8 particles (so every photon should be posting data to 4 different url’s with different auth bearers). That would bring us to 32 webhooks on one account. And that isn’t going to work. Why not? Well…Failed to create, server said Too many web hooks for this device Potentially unhandled rejection [1] {“ok”:false,“error”:"Too many web hooks for this device"} (WARNING: non-Error used) You are alloud to create 10 hooks.
So I thought…what if I push it all into one webhook. So, 32 events in one webhook and the publish event will differ for every user.
But how? Anyone got a clue on how I should put 32 events into one webhook?
My guess would be that only the second event is actually triggering the webhook, since they both share the “event” key in that JSON dictionary. Have you tested if post_hcptemp_01_01 is doing anything?
You could maybe work around the limitation by letting each user claim the Photons they’re posting events from.
From a logical standpoint, it sounds you are better off consolidating to one type of event+hook with some distinguishing information in the JSON body (like username/device ID and subevent type). If the URLs really need to be different, perhaps you can have a middleman server that relays events based on this data to the right URLs.
I don’t see any reason why you couldn’t even just replace the entire url with “{{custon-url}}” and post webhooks completely dynamically if you wanted to, unless Particle imposes some character limitations on variable substitution.
Registering the photons onto different users would be a quick solution, but not really a pretty one since I don’t want to hassle the users with registration. I would like to maintain them from one email adress. The URL’s are all differing because they are related to the so call S-user at SAP. This username is located within the URL. I also tried to push a part (the username) of the URL into the coding, but I wasn’t able to get that working as well. That might be a solution, but how?!?! Having a server in the middle would be a solution as well but that would also be another workaround and too much trouble for a workshop.
I’m also just now working on posting logs to a Slack channel with a configurable URL as the post destination, so hopefully I’ll have a working example soon.
I had been on the right track from the beginning, but the quotes were in the wrong place. %s should have been “%s” and for that reason the user did’nt end up in my URL. So now I’ve pushed in the user and device id, that are part of the URL, in there and the bearer oAuth token as well. Thanks a lot for the help @indraastra!