REST API with HTTP Status response

REST API with HTTP Status response

  
We are creating a new REST integration, the methods of these API kan have a JSON response but also a HTTP Status response. How can we get this Status Code and Status Text and avoid having an exception on HTTP Error codes.
Hi Matthias,

Have you tried using the OnAfterResponse event (in your REST API properties)?
Look for properties Response.StatusCode and Response.StatusLine.
I changed the Response StatusCode and StatusLine, but the error is stil logged, the Exception handler of the OnAfterResponse has Log Error property set to No.

So, what's the problem?

I understand the error is logged (due to some xif throwing the error, hence it will be logged no matter what)
But it is continuing, no?



I don't want the error logged, because it is already handled the HTTP Error code is a functional error code returned by the REST API. In the Error log I only want to see real (unexpected) technical errors.

Statler & Waldorf and the amazing flappy tweedles! wrote:
So, what's the problem?

I understand the error is logged (due to some xif throwing the error, hence it will be logged no matter what)
But it is continuing, no?


 
 
 
Hi,

You are changing the status in the ModifiedResponse output, right?
I I'll test it, but I'm pretty sure it should not log an error if you change it to a non-error status code (20x range)

Can you post the error stack that you in the error log?

Regards,
João Rosado
Stack:
409 Conflict
   at ssMPM_TSAP.CcTimeseriesMainenergie.ActionREST_MAIN_PostDealForecast(HeContext heContext, ICcTimeseriesMainenergieCallbacks _callbacks, STREST_DealStructure inParamRequest, String& outParamResponse)

Solution
Hi again,

Just tested and worked as expected, no error logs after changing the Status Code in the Customized.

Did 4 calls to my action, 2 before and 2 after changing the Status Code.
The calls at "21:51:17" and "21:51:20" are before the change.
The calls at "21:52:09" and "21:52:11" are after the change.

My error log:


My Integrations Log:


And the change in did on the OnAfterResponse callback:



Regards,
João Rosado
Solution
That solved it, in my OnAfterResponse i only changed the CustomResponse.StatusCode to 200 in the exceptionhandler. Now i added it also to the normal flow.

Thanks for your help!
An additional question about this subject: In the service there is also detailed error information in the Response.Text.

The above sollution returns the StatusCode en StatusLine via Session variables; is it also possible to return the response text?