How to make an ajax request from script include in ServiceNow.

dev115415
Tera Expert

How to make a REST request from script include in ServiceNow.

I want to send an ajax request to an external application and then fetch data from that. I am able to do it in ServiceNow client script using jquery but how to do this in Script include?

Thank you

1 ACCEPTED SOLUTION

Elijah Aromola
Mega Sage

A Glide Ajax is used to make server requests from a client script. So you would use that in a scenario where you have a client script and a script include. The client script would call the script include using the Glide Ajax API to execute the server script. 

 

If you need to make an API call to an external application inside of a client script, you would have to make the REST/SOAP call inside your script include, and call the script include from the client script using a Glide Ajax. 

 

Glide Ajax cheat sheet from another community member: https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430

 

RESTMessage v2 API: https://developer.servicenow.com/dev.do#!/reference/api/utah/server/c_RESTMessageV2API

View solution in original post

2 REPLIES 2

Elijah Aromola
Mega Sage

A Glide Ajax is used to make server requests from a client script. So you would use that in a scenario where you have a client script and a script include. The client script would call the script include using the Glide Ajax API to execute the server script. 

 

If you need to make an API call to an external application inside of a client script, you would have to make the REST/SOAP call inside your script include, and call the script include from the client script using a Glide Ajax. 

 

Glide Ajax cheat sheet from another community member: https://www.servicenow.com/community/developer-articles/glideajax-example-cheat-sheet/ta-p/2312430

 

RESTMessage v2 API: https://developer.servicenow.com/dev.do#!/reference/api/utah/server/c_RESTMessageV2API

Hello

I want to  make an API call to an external application from Script Include. How to do this?