As far I know arrays/lists are not supported currently in response templates. So it’s not possible to implement your desired message structure unfortunately.
@Philipp_Emmel Might correct me here or can give you additional hints if I’m wrong.
Defining key/value pairs from an array of objects does not seem to be supported in the custom SmartREST template builder.
However there is nothing wrong with using your proposal (e.g. id1,id2,val1,val2), apart from being “unexpected for a developer”, but that should not stop you from using it.
If you want to find out the array length by using the following formula:
Where the total_fixed_fields would be 2 in your case (as the first field is the message id 11, and the second field is the device’s external id).
Alternatively if you wanted to send a large list of parameters, then you could just send the URL as part of the SmartREST template where the operation handler could download the parameter list via the thin-edge.ioCumulocity Proxy.
Interesting. I saw this [*] pattern somewhere, I think in the preview of the pattern field but I did not know that it is actually supported. Did you find this somewhere in the docs?
We may not support the full scope of JSON Path and we also don’t use the most recent version. So there is always a bit of trial and error necessary to get things working exactly right especially with complex arrays like in this operation data model. The correct way to address what you what to address in JSON Path would be parameterWrite.parameters[*].[id,value]. However I was not able to make this work with SmartREST.
Thanks all, that’s useful information. Also did not succeed in making parameterWrite.parameters[*].[id,value] work in Smart Rest.
But that’s okay - I’m going to use the format that outputs id1,id2,value1,value2 then.