on ‎2023 Apr 24 4:53 PM
Hi Folks,
I've got a problem using the JSON serializer classes: the ones I've tried are returning a string that doesn't match the requirement of my external REST API, which is hosted by Kepware KepServer 6.13.
The serialized JSON body (string field) for a successful POST call to update a single tag needs to have precisely this format:
[{"id": "Channel1.Device1.Order", "v": "717999"}] - where Channel1.Device1.Order is the tag id, and 717999 is the tag value.
I arrived at this format after exhaustive testing using Postman. Nothing else seems to work. For serializing, I have tried classes CL_TREX_JSON_SERIALIZER and CL_FDT_JSON, both of which return a string that looks like this:
[{"NAME":"id","VALUE":"Channel1.Device1.Order"},{"NAME":"v","VALUE":"000000717999"}]
I'm passing a single record table in the serializer call, with field names 'NAME' and 'VALUE', which is clearly wrong. But exactly what should I be passing? How do I avoid the ABAP field names appearing in the serialized string? Not to mention the extra }{ characters in the middle, which Kepware doesn't like. I've tried just using a table of strings (ABAP type STRINGTAB), but if there's a right way I haven't found it.
Is there a neat short cut for this? Or will I have to use a transformation (hoping not to; I've only used them for XMLs, no idea how to do it for JSON format).
Thanks for reading, grateful for any constructive comments/answers.
Cheers
John
Request clarification before answering.
| User | Count |
|---|---|
| 9 | |
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.