Automatic deserialisation failing when consuming a Rest API

On O11, Reactive Web projects, are there any known issues with the automatic deserialisation of the Response from a Rest API into a local variable?

Problems steps:

  1. Created a "Consume Rest API" GET based on manual example response JSON from a vendor.
  2. Successfully Tested in the API window.
  3. Response data type structure generated apparently correctly, just amended one element which was badly named (named after the "value" in the response JSON, not the "name", the element is a bounding element, not a data carrying element).
  4. Created a local variable in the scope of a web page using the generated data type.
  5. Created a client action to call the API.
  6. Local variable does not get populated on response from the API.

Troubleshooting steps:

  1. Added an "OnAfterResponse" action and put a breakpoint in to debug.
  2. The Response from the API is as expected.
  3. Stepped through the breakpoint, local variable still not populated.
  4. In the same "OnAfterResponse" action, added a JSON deserialiser using the API response and the generated data structure, and that works - the deserialised response populates the data structure correctly.
  5. Stepped through the breakpoint, local variable still not populated.

Workaround:

  1. Changed the API method to return Text instead of JSON.
  2. Added a JSON deserialiser in the client action (outside the API).
  3. JSON deserialiser correctly interprets the JSON stored as text and populates the data structure.
  4. Used an Assign to pass the deserialiser structured data to the local variable.
  5. Success.

None of my other API calls require this manual deserialisation and assignment of data to a local variable, they all work with the automatic/implied assignment to the local variable based on the local variable having the API's response data structure.

One possible issue is that the API is returning image data, but I don't know whether that's a problem.

Any ideas?

Hi Andy,

There might be a difference between the JSON deserializer and what happens when the platform processes the REST responses, however it is unlikely.

Without seeing an example I can't really tell based on your descriptions.

However you mentioned 2 things that might give you some extra clues:

  • You "amended" one of the elements, so please check on the properties of the JSON the names displayed by the platform vs the names it is searching on the JSON, this property is often forgotten and you might be getting unexpected results. 

so under the data, structures check that more button


and check that name in JSON


  • You also mentioned "image data", this is usually transmitted using a base 64 text encoded attribute. It is interpreted as a text by the platform when you paste the JSON, but if you change the data type of the attribute to binary, the platform will automatically convert it to binary.

Not sure if this helps at all, perhaps you can share with us a small oml exemplifying what you describe, hopefully that REST you are consuming is not a super secret or private service, so we can take a look.


Cheers