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

Martin Ivanov
Giga Sage
Giga Sage

You can do it in UI action. You'll have to define a rest message with the details of the tird party - url, auth, parameters etc. Then when you define the REST message and the method, open the method and you'll se a button "Preview script usage" There will be an example on how to call this.

Please refer to the amazing series of Chuck Tomasi: https://developer.servicenow.com/blog.do?p=/post/learn-integrations-now-platform/

Please Mark Correct AND Helpful. Thanks!


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

Thanks for the response, 

Can't we do that in App Engine Studio....UI Builder?

like creating some fields and on clicking button, it should call an API and render in UI.

Sai Kumar B
Mega Sage
Mega Sage

@susmita 

Yes you can do, try the below approach

1.) Create REST message with an Endpoint

Reference - https://docs.servicenow.com/bundle/rome-application-development/page/integrate/outbound-rest/task/t_...

2.) Define a REST message HTTP headers

Reference - https://docs.servicenow.com/bundle/rome-application-development/page/integrate/outbound-rest/task/t_...

3.) Define a REST message HTTP method

Reference - https://docs.servicenow.com/bundle/rome-application-development/page/integrate/outbound-rest/task/t_...

Once you define all the above, In the REST message record you can see the "Preview script usage" related link. Click that to preview the code and copy/paste the code at any server-side script to retrieve data from third-party API

Perfect Examplehttps://community.servicenow.com/community?id=community_article&sys_id=ad8ad908dbdc7b44a39a0b55ca961...

 

This somehow repeats what I've written above.


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