Outbound REST Integration

Akshay Pithore
Tera Contributor

Use case: If an incident is created in source ServiceNow instance it should be created in target ServiceNow instance.

ServiceNow stores details on how to interact with external web services through REST in a REST Message record. The REST Message record includes:

  • Endpoint (URL &Address)
  • Authentication (login details/Credential)
  • HTTP Headers (Request body)
  • HTTP Method (CURD)
  • Step1: Creating an Outbound REST Message (on source ServiceNow instance)

To create an outbound REST Message, use the All menu to open System Web Services > Outbound > REST Message>New.

AkshayPithore_12-1751519844619.png

 

 

 

  • Name: A descriptive name for the REST Message. This value is used when invoking the outbound REST Message from a script.
  • Endpoint: The endpoint where this REST message is sent. On target ServiceNow instance go to >System web services> Rest API Explorer>Explorer>copy instance URL>use on source instance in rest message endpoints.
  • Authentication type: The type of authentication to use, if any, and the profile record that contains the user credentials. Outbound REST supports basic authentication and OAuth 2.0. The authentication configured here is inherited by the associated HTTP methods. You can configure authentication for each method which overrides any authentication setting at the message level.
  • Use mutual authentication: Select to require both the web service provider and consumer to authenticate with each other before communicating. Outbound REST supports mutual authentication with basic authentication only.
  • HTTP Headers: Double-click a row in the HTTP Headers embedded list to define the header Name and Value. The web service provider determines which headers are supported or required. See List of HTTP Header Fields for a list of HTTP header fields.
  • Step2: Authenticating in an Outbound REST Message
  • Different web service providers may require different types of authentications. Outbound REST supports the following authentication formats:
  • No authentication
  • Basic authentication using a username and password.
  • OAuth 2.0 using an OAuth provider and profile.
  • Mutual Authentication
  • 1)No Authentication Some public web services distribute free information without authentication. For public web services that do not require authentication, set the Authentication type field of your outbound REST message to No authentication.
  • 2)The Basic authentication type passes a username and a password to the web service. For web services requiring Basic authentication, set the Authentication type field value of your outbound REST message to Basic, then select a Basic auth profile.
  • go to target ServiceNow instance go to profile manage instance password copy username and password.
  • and use on source instance.

AkshayPithore_13-1751519844626.png

 

 

 

  • A Basic auth profile consists of a Name, Username, and Password.

AkshayPithore_14-1751519844631.png

 

 

 

  • Type sys_auth_profile_basic.list into the Filter field in the All menu to edit or create a new Basic auth profile.
  • 3)OAuth: OAuth is an Internet standard that provides users with access to APIs without giving them a password. See the How to setup OAuth2 authentication for RESTMessageV2 integrations blog post for information on setting up OAuth.

    4)Mutual authentication:

    Mutual authentication requires the web service provider and consumer to authenticate with each other before communicating. Mutual authentication is a protocol/socket-level authentication compared to other authentication options, which are application-level authentications. Mutual authentication can be used in conjunction with other authentication mechanisms. To enable mutual authentication, select the Use mutual authentication option then select a Mutual authentication profile.

     

    To define a Mutual authentication profile, use the All menu to open System Security > Protocol Profiles.

    This option is not available for web services that use a MID server.

     

    • Step3: HTTP Methods

    HTTP methods define the action to take for a resource, such as retrieving information or updating a record. When a new REST Message is saved for the first time, ServiceNow creates an HTTP Method based on information in the REST Message.

     

    AkshayPithore_15-1751519844636.png

     

     

    Click the HTTP Method name to open the method for editing or click the New button to create an HTTP Method. The available HTTP Methods are:

    • GET-Get records information.
    • POST-Creates records.
    • PUT-Modifies records.
    • PATCH-Updates records.
    • DELETE-Deletes records.
    • Step4: Method Endpoint & Configure POST Method
    • On target ServiceNow instance>Navigate to All>System web services> Rest API Explorer>Explorer>copy>instance URL
    • and use on source instance endpoints.
    AkshayPithore_16-1751519844639.png

     

    • Step5: Method Authentication and HTTP Request Authentication In the default case, HTTP Methods inherit authentication settings from the outbound REST Message (parent). Change the authentication type if it differs from the parent's authentication. The authentication fields for the method are the same as for the outbound REST Message
    AkshayPithore_17-1751519861542.png

     

     

     

     

    • HTTP Request - MID Server If the web service to be consumed is on an internal company network and not accessible using the Internet, use a MID
    • the Use MID Server field.

    HTTP Request - HTTP Headers

    Double-click the text Insert a new row... in the HTTP Headers embedded list to define the Name and Value for a header. The web service provider determines which headers are supported or required. See List of HTTP header fields for a list of HTTP header fields.

    Headers

    Content-Type: application/Json

    Accept: application/Json

    HTTP Request - HTTP Query Parameters

    To define an HTTP Query Parameter, double-click the text Insert a new row... and provide a Name and Value for the parameter. Refer to the API's documentation to see which query parameters to define.

    JSON:

    {

    "key":"value"

    }

    key means column in ServiceNow

    for example:

    {

    "Number":"INC0012"

    "short_description":"test"

    }

    Add the query parameters to the endpoint.

    AkshayPithore_18-1751519861557.png

     

     

    Running the Test

    To test the HTTP method, click the Test related link.

    AkshayPithore_19-1751519861557.png

     

     

    The test results are available in the Test Runs related list.

    AkshayPithore_20-1751519861562.png

     

     

    Check the target ServiceNow instance incident created.

    AkshayPithore_21-1751519861568.png

     

     

     

    • Dynamic content of JSON:For example: {"column_name":"${details}"},

    Doller represent dynamic content.

    • Now the requirement start here is I don't want to click on test let automate it so, if I create an incident on source ServiceNow instance on incident table it should create the incident on the target ServiceNow instance.
    • Dynamic content of JSON:AkshayPithore_22-1751519861569.png

       

       

      • Business Rule script: on source ServiceNow instance
      • on HTTP Method record preview the script usage copy code paste on BR And make some changes as per your requirement.
      AkshayPithore_23-1751519861599.png

       

       

       

      • create a new incident on source ServiceNow instance and submit.
      • check on target ServiceNow instance.

       


Please mark this response as correct or helpful if it assisted you with your question.
1 REPLY 1

Sujit Jadhav
Tera Guru

Hello @Akshay Pithore ,
Helpful article
Thanks for Sharing