How to send request to third party application after approval of request?

vimal11592
Tera Expert

up votedown votefavorite

Hi,

I am trying to call the third party application using script in service now workflow.When someone request a item from service now catalog It goes for approval to admin.Once admin approves the request incident status is approved.But before ending the workflow I want to run script to call some third party application API and do some task using script.

  • My first question is : is this possible to call third party app from workflow script?
  • Second Question : can someone please guide me how to call third party app if possible?

Thanks,

Vimal Mishra

6 REPLIES 6

veeresh3
Tera Expert

Hi,



First : Yeah it's possible to call third party application.


Second: To call third party application you   must have knowledge of SOAP or REST web services. For this u have to write a SOAP or REST script in 'script action' and   create a event, attach your script action to the even and you can call that event in the workflow.



For more info about Web service, Please go thought Web Services - ServiceNow Wiki .




If it's helpful,   please mark as correct or helpful.




Thanks,


Veeresh


Hi Veeresh,



Thanks for the reply.


I am using ruing Run Script from the utilities section to make call to third party application.I am very new to this so I don't know how to write script in that,Please find following script that I have added :



var r = new RESTMessageScripted("get","http://<hostname>/auth/signin");


r.addHeader("Content-Type","application/json");


r.addHeader("Accept","application/json");


r.setBasicAuth("username","passowrd");


var response = r.execute();


gs.log(response.getBody());




I am getting following error whwn I run the script:



Caught exception in InterpretedScript <refname>: org.mozilla.javascript.JavaScriptException: ReferenceError: "RESTMessageScripted" is not defined.


(#0(eval); line 1)



Thanks,


Vimal


Vikas-Malhotra
Mega Guru

Hi Vimal,



Yes, you can definitely call third party app from workflow script.


If you are trying to call this third party app using a rest web service, then you can create a "Rest Message" in workflow to complete your request.



Else you can let me know as how do you want to call your third party application from workflow?



Thanks and Regards,


Vikas Malhotra


Hi Vikash,



Thanks for the reply.


I am using ruing Run Script from the utilities section to make call to third party application.I am very new to this so I don't know how to write script in that,Please find following script that I have added :



var r = new RESTMessageScripted("get","http://<hostname>/auth/signin");


r.addHeader("Content-Type","application/json");


r.addHeader("Accept","application/json");


r.setBasicAuth("username","passowrd");


var response = r.execute();


gs.log(response.getBody());




I am getting following error whwn I run the script:



Caught exception in InterpretedScript <refname>: org.mozilla.javascript.JavaScriptException: ReferenceError: "RESTMessageScripted" is not defined.


(#0(eval); line 1)



Thanks,


Vimal