How to access response body for 400 status POST request

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2017 01:53 PM
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.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2017 03:51 PM
oh ok, try below
responseBody = response.haveError() ? response.getErrorMessage() : response.getBody();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2017 04:15 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2017 07:46 PM
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):

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2017 05:04 AM
Thank you! That's what I was looking for.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2017 07:52 AM
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.