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.

Scripted Rest API Not working

rambabu1
Giga Expert

Hi All,

below is the script that i written on scripted rest api. but its not working when i send data like https://google.com/gtre

can any one help me on this

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

var obj = {};
obj.number = request.pathParams.number;
obj.worknotes = request.pathParams.work_notes;
var gr = new GlideRecord("sc_req_item");
gr.addQuery("number", obj.number);
gr.query();
if (gr.next()) {

gr.work_notes = obj.worknotes;
gr.update();
response.setBody(obj);

}

})(request, response);

 

 

11 REPLIES 11

Hi Ankur,

but here i need to post the data in worknotes when automation is success. in that automation i received the output like URL format. 

for that URL format i am receiving like "request uri does not conatin any resource"

You should encode your url

https://fsfe.ciewri/rjwerj

https%3A%2F%2Ffsfe.ciewri%2Frjwerj

For testing use

https://www.urlencoder.org/

 

 

Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Vinod Kumar Kachineni
Community Rising Star 2022