Issue with SetResponseCode

Hi All,

I am getting some issue with setResponseCode service. We can use this service to set specific response code for APIs and working fine. But same service when using inside catch block its not working and always setting default response code as 500. Is there any way to overcome this step.

Please Note: in catch block after using setResponseCode we are using Exit-flow to mark service as failure.

Thanks
Baharul Islam

Use setresponsecode2 recommended.

The technical error should be masked as 500 Internal Server Error and not throw the actual error.

If you intend to use other http status code let me know and share the flow snippet probably screen shot should do.

Thanks @Mahesh for your reply.

However I am using wM version 9.7 and there is no option for setResponseCode2 service.

I am trying to set different http response code other than 500 from catch block .Please find attached screenshot for ref…

Thanks
Baharul Islam

Service_ScreenShot.PNG

Try the following: in the try-catch block just set a flag indicating whether an error occurred. Then set the response code as appropriate but do it not within the try-catch block.

But at the end of the catch block I need to call Exit-flow to mark service status as failure.