REST request.getRequestBody() & response.getQueryString() do not work on scripted REST

shayyoung1
Kilo Contributor

Hi,

I cannot get this to work at all.

any help would be appreciated

response = sm.executeAsync(); //Might throw exception if http connection timed out or some issue with sending request itself because of encryption/decryption of password.

  response.waitForResponse(60);// In seconds. Wait at most 60 seconds to get response from ECC Queue/Mid Server //Might throw exception timing out waiting for response in ECC queue.

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

  status = response.getStatusCode();

}

catch(ex)

{

  responseBody = ex.getMessage();

  status = '500';

}

finally

{

  requestBody = sm ? sm.getRequestBody():null;

}

workflow.info("Request Body: " + requestBody);

workflow.info("Request Body: " + response.getQueryString());

workflow.info("Response: " + responseBody);

workflow.info("HTTP Status: " + status);

7 REPLIES 7

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Shay,



Please refer sample example in the below link and adjust your code accordingly.


Scripted REST API example - script samples


Hi,



i am executing a REST message and need to know what the outbound URL is that is being sent.



it is a scripted outbound rest i have not a rest api.



Thanks,


Shay


snehabinani26
Tera Guru

Hi Shay,



Try this code.



request.queryString


request.body



and check whether this is returning values.


Paramahanns
Tera Expert

Hi Shay,



Where are you executing this code.



Regards


Param