How Can I Display the request body of an API Call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 04:50 AM
I am working on an outbound SOAP call, and trying to debug it. The team I am working with is unable to provide me with the request of the API call they receive, so I was attempting to view it from within ServiceNow to see where the error is coming in.
I have turned on Extended logging for the API method, but when I view Outbound HTTP Requests, the request's body is empty.
I attempted to modify my UI Action to collect the Request Body (in addition to the Response Body), but it gave me an error message. My code is:
// Execute SOAP request and get response
var response = sm.execute();
var ResponseBody = response.getBody(); //get the response as a string, so we can parse it later
var requestBody = request.body; //get the request body so we can view it
var requestString = requestBody.dataString; //convert to a string
gs.log('Request body is ' + requestString);
gs.addInfoMessage('Request is ' + requestString);
I've been searching for the solution, and I'm sure the problem is the "request.body", but I cannot find the code to fix it in the reference docs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-20-2023 02:48 PM
Well, I never did figure out how to retrieve the request.body, but I did manage to figure out what was wrong with my HTTP output not showing the body. It turns out it's multiple things. Here's what I found:
- Change the system to debug SOAP calls. I'm not sure which was correct, but I created the following system properties and set them to 'true'
glide.processor.debug.SOAPProcessor
glide.soap.debug - Change the HTTP Log level to "ALL" (the other levels don't show the body.) This will show the body but ONLY the first 100 characters.
- Change the system property glide.outbound_http.content.max_limit to a number larger than 100.
Hope this helps someone else.