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
Hi Rajendra,
Try the following:
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.
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.
Thanks kilian,
It got fixed by restarting the server.
Thanks for the explaining,how json object worked.
You're most welcome :). Happy coding!