Is it possible to use mustache notation inside a webhook in order to put a string received from a Photon into the “Headers” section of my webhook? The Photon is sending up something that looks like this as the data during particle.publish()
where I’ve tried using {{PARTICLE_EVENT_VALUE.access_token}} and also {{access_token}} among many other attempts. These ones make the most sense to me though, but I’m not having any success and was just wondering if I’m restricted from doing this in this section of the webhook or something? Or maybe it has to do with trying to include the "Bearer " at the beginning but I didn’t think this would matter since the mustache template seems to just be direct text substitution. Also is there any way to view what that substitution value ends up being after the substitution before the request is sent? That would definitely aid my debugging process. Thanks in advance!
Make sure the string isn’t getting truncated. The publish size limit is 255 characters, so if you exceed that the end of the data will be missing, the JSON will be invalid, then no mustache templates are expanded.
@rickkas7 Thanks! I found your mustache tester and that is very helpful to see. I will look into RequestBin as well. The access token that is sent is usually about 144 characters which fits but the rest of the object (which I don’t need) might put it over 255. However, I’m able to read out the whole object with all data fields intact on the online console:
@rickkas7 Thanks very much! The example was helpful and RequestBin turned out to be super helpful, definitely a useful resource. It turns out you were right originally, the response object was being truncated (despite being shown fully intact on the console when the photon sends its data response, not sure why) so I’m assuming that because it wasn’t terminated properly (i.e } ) the mustache template’s access attempt did not work because the data wasn’t a recognized as a full object, technically probably just a string. So I just parsed out the part I needed in the firmware on the photon and then just sent that up and it worked