How to pass unescaped JSON to Azure IoTHub?

I no longer have that image or remember what it was unfortunately.

I ditched Azure for Losant.

I fixed it. The setup was already made in Azure, but thanks for the reply :slight_smile:

1 Like

Can this screen be reposted?

I am still having this issue has there been a solution?

So with ordinary webhooks you can enter data like this. The line is flagged as an error, but you can still save the webhook, and it works.

However, with the Azure integration it appears that you cannot save a webhook with JSON that does not currently parse, but might parse correctly after the mustache template expansion.

A bug report was created for this to be investigated by engineering as it seems like it should work the same as regular webhooks.

1 Like

We removed the check for JSON that does not parse at the time you enter it for Azure webhooks so if you click to the Custom JSON tab you can now enter this and save it:

{
  "event": "{{{PARTICLE_EVENT_NAME}}}",
  "data": {{{PARTICLE_EVENT_VALUE}}},
  "device_id": "{{{PARTICLE_DEVICE_ID}}}",
  "published_at": "{{{PARTICLE_PUBLISHED_AT}}}"
}

Note that the value for data is no longer surrounded by double quotes, so it’s flagged as an error. However, when the Mustache template is expanded and the event data contains valid JSON, it will send the data up as a JSON object instead of a string. Also make sure you use triple curly brackets {{{PARTICLE_EVENT_VALUE}}} to prevent HTML escaping in Mustache.

This can also be used so send up true numbers, instead of requiring numbers encoded as strings.

3 Likes

Any chance to remove this check also for regular webhooks? This will solve tons of other issues people had with unneeded escaping.

Allowing bypassing the check for JSON that does not parse at the time you enter, before template expansion, already worked for regular webhooks. It was only recently modified for Azure webhooks to allow bypassing as well.

With regular (non-Azure) webhooks you can either use json or body to create webhooks that create valid JSON only after mustache template expansion, even if the template itself is not valid JSON before template expansion.

2 Likes