SMS_HTTP template x device.attributes with JSON array

FK42 years ago

Greetings,

I'm using SMS_HTTP to post data into a notification server, and I have this configuration line at my ../templates/short/geofenceEnter.vm

...
'deviceAttributes':'$device.attributes',
...

In device.attributes I have a PHP json_encoded array, saved as:

{"126941":{"invoiceId":"126941","invoiceNb":"NFE 071600","driverId":"153"...

And it is sent as text, making it impossible to json_decode again into array::

{126941={invoiceId=126941, invoiceNb=NFE 071600, driverId=153...

Does anyone have any clue on how to handle this inside a template, so that I get a clean string back as expected?

Thanks for any help!

Anton Tananaev2 years ago

Why are you not using event forwarding instead?

FK42 years ago

Well, that I didn't know!

Did some research in your documentation, played with it and the package comes in perfectly fine! Awesome!

But, I needed $user.name or $user.email into this event forwarding POST to manipulate information for db schema on my side. Is there any way to inject this as, for example, a header? Something like:

traccar.xml: < entry key='event.forward.header' >Custom-Header: '$user.name'< /entry >

Or any other way?

Anton Tananaev2 years ago

We used to include it before, but now it's hard to do because we don't have access to user info at the time of forwarding.

FK42 years ago

Ok, I'll then inject my string information at geofence.attributes.

And thanks again for the event POST forwarding!