How to access response body for 400 status POST request

Joseph Gabriel
Tera Contributor

I have a scenario using the RESTMessageV2 object to execute outbound REST API requests.   Depending on the data included in the request, it may fail with 400 error code, and the body of the response contains the actual information explaining why the request failed.

I need to read the body for a failed POST request so that I can create a helpful error log.   Currently, I cannot see any way to access the actual response body for 400 level responses.

Please advise.

9 REPLIES 9

oh ok, try below



responseBody = response.haveError() ? response.getErrorMessage() : response.getBody();


I have tried those things, but it only gives me the high-level error. The detail that I need is only available in the actual response body.



Is there no way just to access the response body or even the raw response directly??



On a successful call, I can access the response body fine, but when the HTTP status is 4xx or 5xx the getBody() method just returns null.


Robert Beeman
Kilo Sage

Hi Joseph,



This is a known issue in all versions previous to Jakarta. See my post about it in this thread (it includes the KB and PRB from HI server):


REST API to 3rd party system


Thank you! That's what I was looking for.


Happy to help, and happy that a fix is finally coming. This issue has been a thorn in my side for a long time now



Please mark the appropriate reply as Helpful and/or Correct as you see fit. It will help other people searching the community for this issue find the answer as well.