Hi Everyone
i am facing one issue.in my application i am trying to consume one api and when some validation message is coming then team is sending as 500 Server and if it is success then they are sending 200 response.
i had a discussion with API team and they are not ok with any change in their part.because of 500 error i am not able to catch the response message with help of OnAfter response event.
we are getting response like below
is there any work around ?if i am getting 500 server is there any way to send this validation message in UI.
HTTP/1.1 500 Server Error
x-event-id: 7fa26779-428e-4a80-ac31-10a8e80c143a
x-event-msg: An error was encountered
x-event-code: 500
x-correlation-id: c2ecba06-6b33-44fa-afd5-1ccd0db69e86
Connection: Keep-Alive
Content-Length: 668
Content-Type: application/json; charset=UTF-8
Date: Thu, 23 Jan 2025 12:47:51 GMT
{
"PartyColletionRs": {
"Status": {
"StatusCode": "100",
"Severity": "Error",
"StatusDesc": "Updation Failed",
"AdditionalStatus": [
"StatusCode": "-810270",
"StatusDesc": "There is another Customer in RM_ACCT table with the same National ID."
},
"StatusCode": "-60676",
"StatusDesc": "Contry and city birth mismatched"
}
]
"RqUID": "7fa26779-428e-3434-ac31-43343434"
Hi @Arkyadeep Bharadwaj
Below Link is full fill your requirements.
Please refer it .
https://www.outsystems.com/blog/posts/handling-http-status-codes-consuming-rest/
Regards ,
Rajat
let me check
@Arkyadeep Bharadwaj you mentioned "i am not able to catch the response message with help of OnAfter response event." - what exact issue you are facing here ?
it is not going to OnAfter response before that it went to the exception because of 500 error
A 500 Server Error when consuming an API in OutSystems indicates an issue on the API provider's side, not directly within your OutSystems environment. However, it could also be due to how your request is structured or transmitted. Here's how you can investigate and resolve the issue:
Steps to Troubleshoot the 500 Server Error
1. Analyze the Error Details
@Arkyadeep Bharadwaj ,
it should first go to the OnAfterResponse, before raising an error.
Have you proof it is not going there ??
You would have to change the 500 into a 200 in there, if you want the error not to be raised, though, are you doing that ?
Dorine
Be very carefull though, doing this type of stuff, the OnAfterResponse is for all methods of that API
@Arkyadeep Bharadwaj Looks like there is an issue the way you are handling the exception in OnAfterFetch.
This is what I have done. I have used a service Mockey (https://designer.mocky.io/) to simulate your API and is available at https://run.mocky.io/v3/e61edded-5351-4446-b1c1-ad71ddddc469. This returns 500 and the response as you shared in your original post.
Here is what in OnAfterFetch
On screen action
you need to handle the status code or exception in OnAfterResponse and customize your response.
Can you provide your API end point so it will be easy to provide you exact solution.