72
Views
5
Comments
Getting old response while consuming the Rest API
Application Type
Reactive

Hi All,

We were consuming one Rest API, it was working as expected, due to the changes in the requirement, one field got added in the response from the Source (.Net ). 

In Order to consume the new updated response, we deleted the old one from the Outsytem service studio. and deleted the structure as well from the service studio, and consumed the Rest again, but still, we are getting the old response. (Previously we were getting one record in the list with old fields, still getting only one record with same structure)

We tried in the other test application; there we are getting the updated response.


WE are not sure from where it's taking the old reference. Can someone help us on this please?



Thanks 

Rajendra Singh

2022-08-03 04-32-50
Ravi Punjwani

Hi Rajendra,

Try the following:

  1. Have you tried debugging? See what comes in the response object.
  2. Add an OnAfterResponse action in your REST API in Outsystems. Then debug further into it. This will make sure you know what was the actual response from the API call.
  3. Enable Logging of your API using Service Center, then look into Integration Logs tab under Monitoring page in Service Studio. See each request you call on this API and see the request / response values.
  4. Test using Service Studio, and see what comes in the response.
2020-05-29 14-07-58
Rajendra Singh

Thanks Ravi,

Apologies for the late reply, yes i had already followed these steps, even when I was testing in service studio, I was getting the expected  response.

Any way that is fixed automatically when I restart the server.


Thanks for your kind help.


Rajendra Singh

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Rajendra,

First, there is no need to delete an old version of REST and/or removing the structures. You can always update via the Refresh REST API context menu item of the API. However, in this particular case, I can imagine it's something you tried to be sure nothing "old" is remaining.

That said, the way the OutSystems Platform maps a JSON response to structures is quite straightforward. First, the structure must be the same, that is, a JSON array must be a list in OutSystems, a JSON object a structure. If that's not the case, an exception is thrown. Secondly, if a JSON object is encountered, the Platform tries to map the object's attributes to the corresponding structure attributes by first checking if there's a structure attribute that has a "Name in JSON" that is identical to the name of the JSON attribute, and if not, if there's a structure attribute without a "Name in JSON" set, that has a name that's identical to the name of the JSON attribute. If both checks fail, that attribute isn't parsed at all, without any error being generated or exception being thrown. Likewise, if there are structure attributes that cannot be mapped, the default value will be kept, and no error or exception occurs. So it's possible that there's only a partial overlap between JSON object and OutSystems structure, in which case only a part of the JSON structure values will be available in your OutSystems code.

To troubleshoot, Ravi has given some excellent points. Personally I'd start with increasing the logging level of the consumed REST API and checking the full response, as that can be done without code changes.

2020-05-29 14-07-58
Rajendra Singh

Thanks kilian, 

It got fixed by restarting the server.

Thanks for the explaining,how json object worked. 

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.