63
Views
9
Comments
500 Server Error when consuming API

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",

          "Severity": "Error",

          "StatusDesc": "There is another Customer in RM_ACCT table  with the same National ID."

        },

        {

          "StatusCode": "-60676",

          "Severity": "Error",

          "StatusDesc": "Contry and city birth mismatched"

        }

      ]

    },

    "RqUID": "7fa26779-428e-3434-ac31-43343434"

  }

}

2020-07-21 19-28-50
Rajat Agrawal
Champion

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

2023-06-14 08-52-52
Arkyadeep Bharadwaj

let me check

2019-01-07 16-04-16
Siya
 
MVP

@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 ?  

2023-06-14 08-52-52
Arkyadeep Bharadwaj

it is not going to OnAfter response before that it went to the exception because of 500 error

2025-08-07 06-30-56
Amit J
Champion

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

  • Open Service Center in OutSystems.
  • Navigate to Monitoring > Integrations.
  • Look for the specific call to the API and review the error details (stack trace, headers, response body).
  • If possible, extract the full error message returned by the API by setting full logging in service center.
2021-09-06 15-09-53
Dorine Boudry
 
MVP

@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

2021-09-06 15-09-53
Dorine Boudry
 
MVP

Be very carefull though, doing this type of stuff, the OnAfterResponse is for all methods of that API

2019-01-07 16-04-16
Siya
 
MVP

 @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



2022-12-30 07-28-09
Navneet Garg

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.

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