How to test the inbound API using the script

vinuth v
Tera Expert

Hi All,

 

I need to check the inbound API in script,

I tried with the giving endpoint in the script like this

 

var restMessage = new sn_ws.RESTMessageV2();
restMessage.setHttpMethod("post");
var username = 'svc';        
var password = '$vc@tr';  
 restMessage.setBasicAuth(username,password);
var response = restMessage.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.print(httpStatus+" "+responseBody);
 
I am getting error like this
 Script: 400 {"error":{"message":"Invalid Quantity value","detail":""},"status":"failure"}

 

I tried with the calling REST message 

 

var restMessage = new sn_ws.RESTMessageV2('Datactics Test', 'Post Datactics');

var response = restMessage.execute();

var responseBody = response.getBody();

var httpStatus = response.getStatusCode();

gs.print(httpStatus+" "+responseBody);

 

It's working but RITM is created, How to restrict the RITM creation when we want to just check the inbound connectivity.

 

Thanks in advance,

Vinuth

2 REPLIES 2

SwarnadeepNandy
Mega Sage

Hello @vinuth v,

What is your use-case?

I see in the first script you are doing a POST to sr_submission_api, which is an API to submit catalog item.
So, even though you are getting an error message, but that is most probably after the RITM creation.

 

Best Regards,

Swarnadeep Nandny

Hi @SwarnadeepNandy 

 

I have added the wrong error message,

 

This is the error message I am getting

 Script: 400 {"error":{"message":"Invalid Quantity value","detail":""},"status":"failure"}

 

I need to check the inbound API connectivity and user name, password in the ServiceNow dev instance. 

Internally I need to do.

 

Thanks,

Vinuth