how to show Error Message returned by REST API?
Application Type


We save our Employees using REST API. If user Name, Email, Employee ID already exists then REST API shows the error. 

Like :  User Name is already exists etc.

"data" : [


    "employeeData: " [


              "Error" : "User Name is already exists"





"paging" : null

We able to save the Data but unable to retrieve above error message from REST API. When we debug then I unable to  find this Error Message in Response. I also created a new attribute called "Error"  in Response output parameter but this is empty.

Can somebody tell me what is the correct way to read this error message. I want to print this message in MessageBox.

Note: It's  a LIVE project so can't share anything here.  


Hey Khris,

OutSystems should automatically generate the Response structure based on the JSON it receives. Maybe you should try consuming the REST API again or you can also add manually the structure based on the JSON. I also noticed the JSON you sent here is not completely valid, but I fixed the errors and generated a structure in OutSystems (there's an option if you right-click the Structures folder - Add structure from JSON) and it looks like this:


"data": [


"employeeData": [


"Error": "User Name is already exists"





"paging": null


If you don't already have it, you can try and manually add it to your response structure and see if it works. Then you should be able to get the error data from your structure.



Thanks for reply Bogdan.


When I run it from Outsystems with the existing User Name then OS created the same structure which you showed. 

but in this case I lost my structure where I can return the response.  

Still during debug I can see Error is EMPTY

If I have proper response then I need to show Response otherwise Error message

I think for this you should create structure first according to success response. After that according to error response just add one more attribute named "error" in that employeData structure. So when ever you get error others will be empty and value of 'error" will be mapped. 

EmployeeeData {






Made this changes too but still I am not getting Error message 

could you please provide both success response and error response and also response structure created right now.

Response =>Data=>EmployeeData=>UserName,Email,EmployeeId, Error [All are Text data type]

Sorry can't share the screen shot

Hi Khris,

Better if you can create a generic response structure that can hold your success data as well as error response . In case you are not able to create a generic structure and in both cases the JSON structures returned by API is different than you can follow below approach

You can write your own logic in OnAfterResponse and you can customize the response text in a way that can de-serialize in your custom structure.

Same as i create a custom structure that can hold the error data as well as the success data

Attached is the working sample for consuming a REST API with two different out puts with two parameter values 1 and 2

Hope this will help.

Best Regards



hey thanks for reply and example

when I try to parse my JSON I  not getting Error field from API.  may be due to this I unable to show error message.

I followed your steps but not getting error yet

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