Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

How to trigger cURL api from business rule or any other Server side script

ramesh_r
Giga Sage

Hi All,

How to trigger cURL API details from Business Rule or any other server-side script

EX : This is the sample API

curl "https://dev82225.service-now.com/api/now/table/incident"\
--request POST\
--header "Accept:application/json"\
--header "Content-Type:application/json"\
--data "{\"active\":\"true\",\"company\":\"9898864641166\"}"\
--user 'admin': 'admin123'

 

I am getting the below error and unable to save the form

find_real_file.png

 

Thanks

Ramesh R

1 ACCEPTED SOLUTION

Goran WitchDoc
ServiceNow Employee

Hi Ramesh,

Why do you want to run a cURL script instead of something like this:

 

var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://INSTANCE_NAME.service-now.com/api/now/table/incident?sysparm_limit=1');
request.setHttpMethod('GET');

//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin';
var password = 'admin';

request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");

var response = request.execute();
gs.log(response.getBody());

//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor’s Guide To ServiceNow

 

View solution in original post

1 REPLY 1

Goran WitchDoc
ServiceNow Employee

Hi Ramesh,

Why do you want to run a cURL script instead of something like this:

 

var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://INSTANCE_NAME.service-now.com/api/now/table/incident?sysparm_limit=1');
request.setHttpMethod('GET');

//Eg. UserName="admin", Password="admin" for this code sample.
var user = 'admin';
var password = 'admin';

request.setBasicAuth(user,password);
request.setRequestHeader("Accept","application/json");

var response = request.execute();
gs.log(response.getBody());

//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor’s Guide To ServiceNow