How to make an outbound REST API call from Service Now

Background:
Over a year ago I began looking into orchestration and using Service Now. I have to say it has been a surprising journey and there is a lot of flexibility in Service now, and the best part is that if you know what you are doing, there is no need to pay for the expensive automation module to do what you have to do. Not only can you make an API call out, you can also create your very own APIs for inbound requests (that will be another article). These API calls can be used in a variety of ways with workflows, service now scripts, etc.

I’m using AWX (Open Source Ansible Tower) but it really applies to anything.

Let’s get started:
To make an outbound REST message

1) Ensure you have access to the REST module.

2) Create your REST message ( parent wrapper)
If you have multiple calls, you should setup a parent REST message so you can inherit authentication, this reduces the number of REST messages you will need. Think of it like a container for all your REST messages going to the same destination.. You dont need to fill out the HTTP Request tab if this is going to be the parent REST Message that other child messages will be using.

3) Enter your HTTP methods
Next is where you actually start putting in your REST Message calls which you can access and use for various workflows and scripts in Service Now. Scroll down around the bottom and Hit the “new” button next to HTTP methods.

You want to Name your HTTP method, select the call type (GET, PUT, POST, etc), then enter in the endpoint which is just the url that the call is targeted to. Also you want to inherit your auth from the parent REST message if you can to make it easier on yourself.

Next move to the “HTTP Request” tab and enter the remaining information for your API call. In this example I am doing a POST to launch an AWX ansible playbook job template.

I am declaring the HTTP header Type, and then placing my JSON payload in the body to send over those values to the playbook. Then hit save

Variable substitutions
If your call required any variables that you are going to be using for your call you should declare them so you can use them in javascripts that may be calling on this REST Message http method.

Then you will enter the name of that variable and put any default value you want to put in there. You can also test your api call with this test value

You can then test your api call by clicking “test” under the related links

If all works well you should have a successful REST call and see the results of your message. In awx this is as simple as looking at the job history.

Thanks for stopping by.