REST API Response different Structures
Application Type
Traditional Web

Hi there,

I have an issue where the structure of the response is different when it is success and when it is fail.

How to solve this using Outsystems?

regards and many thanks 

Solution

Thank you all,

I am thinking to put in a text type and then check if error, then serialize to typeA, else type B in the respons call back event handler.

thank you

Yes, that's a good idea.

Hi,

Try to use if condition, if success then assign the response to success structure, and if fail to assign the response to the fail structure

Regards

Shradha

Champion

Hi IBOX,


In my case, put the structure as one when success and failed.


example :

if success :

{

  "value": 100,

  "description" : "lorem ipsum"

}

and if failed :

{

  "errorCode": 112,

  "errorMessage": "Role not authorized"

}

you put on the structure like this :

{

  "value": 100,

  "description": "lorem ipsum",

  "errorCode": 112,

  "errorMessage": "Role not authorized"

}

Then when error you check is empty the error part.

Hello 

Can you create one manual structure and use the required fields in both type of responses respectively? 

If yes, this may help you to create manual structure: https://www.outsystems.com/forums/discussion/62888/rest-api-with-response-manual-structure/


Regards

Solution

Thank you all,

I am thinking to put in a text type and then check if error, then serialize to typeA, else type B in the respons call back event handler.

thank you

Yes, that's a good idea.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.