top of page

How to create an HTTP Request (REST Message) within ServiceNow

  • Writer: Daniel Macias
    Daniel Macias
  • Mar 10, 2021
  • 3 min read

Updated: Mar 15, 2021

The first thing we are going to do is create a REST Message. Think of a REST Message as a parent of HTTP methods. All HTTP Methods we make within this REST Message will inherit its values. These inherited values include API Endpoints and Authorization.


So let's get started!


Navigate to System Web Services - Outbound - REST Message.



Once you are in the REST Message table, click "New" on the top left of the form to create a new REST Message.



Fill in the following fields:


  • Name: Reference to your REST Message (This can be whatever you want)

  • Endpoint: The URL endpoint for your API (given to you by your API)

  • Authentication type

o No authentication: what it sounds like.

o Basic: Authentication using the username and password of a user-defined in your

ServiceNow instance.

o OAuth 2.0: Authentication using an OAuth Entity profile. This Entity profile will be

used to retrieve a bearer token for your HTTP Request. If you need help setting up

OAuth 2.0, check out my other blog here.



Then click "Submit".


After creating your REST Message, your first default HTTP method will be generated at the bottom of the page in the HTTP Methods table. We're going to go into this HTTP Method and update it to suit our needs.



Click on the Default Method's Name to navigate into it. By default, ServiceNow will automatically populate, Name, HTTP method, Endpoint, and Authentication type.


The only values you will need to worry about changing are:

  • Name: This can be whatever you want.

  • HTTP method: The type of request that you want to make. Select the one that suits your needs.


After you have defined your HTTP Method, you will most likely need to pass along data with your request. We can pass this data in the HTTP Request tab.



In this tab, we will be able to pass data in 3 ways:

  • HTTP Headers: Here, you will need to fill in the header's name you want to pass and the value of that header.

  • HTTP Query Parameters: Like HTTP Headers, you will need to fill in the Name of the query parameter you want to pass and the value of that parameter.

  • Content: Only visible with POST, PATCH, and PUT requests, but you can pass data there as well.


(In this example, I am only passing a Query Parameter)


Now, if you want to dynamically pass data to this request, you will need to use variable substitutions.


First, replace the value of the data you want to pass with ${name_of_variable_here} (This works for HTTP Headers, HTTP Query Parameters, and the Content section).



Next, in the related links sections, click "Auto-generate variables".



After the page reloads, in the variable substitution table at the bottom of the form, you will see a new entry (or entries) matching the value inside the brackets you created earlier. Using this variable substitution, you can pass data through scripts or test values.



From here, you can do a couple of things:

  • Use your HTTP Method in a script: Click on "Preview script usage" in the Related Links section to have a code snippet generated, which will allow you to use this HTTP Method in any scripts you may have.


  • Test your HTTP Method:


Testing your HTTP Method


Testing your HTTP Method is a relatively straightforward process done by populating the "Test value" column of your Variable substitutions.



After you filled out your test value(s), click on "Test" in the Related Links section.



After a few moments, you will be taken to a separate page where you will see your API's response!



Comments


© 2021 By Daniel

bottom of page