Can I call an API from form on ServiceNow?

susmita2
Kilo Contributor

Hello, I'm new to ServiceNow. I'm working on integrations and requirement is can we make a call a third party API from ServiceNow via form(UI, by clicking on button, should call API and get response/render on UI). Can we do this? any reference or videos are helpful.

Thanks in advance.

 

8 REPLIES 8

Ankit Dubey5
Kilo Guru

Yes, it is possible to call REST Message from a UI Action.

 

Using client side UI action -> Check the client check-box on UI Action and use GlideAjax for rest API call. get the response from Rest service and return it back to UI action. After getting response In Client UI action You can set the value by use   g_form.setValue() function.

 

Using Server Side UI Action -> Uncheck the client check-box on UI Action, call the REST API from the script directly.

Hitoshi Ozawa
Giga Sage
Giga Sage

The usual way is to write a Script Include that uses RESTMessageV2 to make the REST call and then have UI Action call the Script Include.

https://developer.servicenow.com/dev.do#!/reference/api/rome/server/c_RESTMessageV2API

 

Sample code in following thread:

Script Include calling REST API

https://community.servicenow.com/community?id=community_question&sys_id=7f8b8c87dbf74c18190dfb243996...

UI Action calling Script Include

https://community.servicenow.com/community?id=community_question&sys_id=0f1183e5db98dbc01dcaf3231f96...

 

 

Martin Ivanov
Giga Sage
Giga Sage

Hi. If some answers have helped you, mark them Helpful and/or Correct in order to close the case. Thanks!


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024

Martin Ivanov
Giga Sage
Giga Sage

Hi. If your issue is resolved and my response has helped, plese consider marking Correct and Helpful. Thanks!

Martin Ivanov

2022 Community Rising Star


Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024