Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to pass JSON data when running REST API request

Mike278
Kilo Explorer

I am using a scripted REST API. From another system, is it possible to send some data in the form of JSON data? How would I go about doing that with a curl command? I can pass the query parameter within the URL, but that's not what I need.

I would like to use the GET method, but I don't believe --data flag can be used with GET. So I would have to use POST.

5 REPLIES 5

Below is how you can parse out data you need or leave it as it.

(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {

	var requestBody = request.body.dataString;
	var j = new JSONParser();
	var obj = j.parse(requestBody);
//if there is id then it will be like obj.id

})(request, response);