The CreatorCon Call for Content is officially open! Get started here.

What to configure with API key

Kishor O
Tera Sage

I have an API key and Endpoint how can I use this and establish the connection with third party tool and servicenow

1 REPLY 1

Riya Verma
Kilo Sage

Hi @Kishor O ,

 

Hope you are doing great.

 

To establish a connection between ServiceNow and a third-party tool using an API key and endpoint, you'll generally follow these steps:

  • Ensure that you have the necessary authentication details such as API Key, Username, and Password if required.
  • Identify the endpoint URL of the third-party tool that you want to connect with ServiceNow.
  • In ServiceNow, you might want to create a new Outbound REST Message or use an existing one.
  • Configure the REST Message with the necessary HTTP headers and parameters.
  • You might need to write a script to handle the connection, API calls, and data processing.

Example of how you might set this up in a Scripted REST API or a Business Rule in ServiceNow:

var request = new sn_ws.RESTMessageV2();
request.setEndpoint('YOUR_THIRD_PARTY_ENDPOINT_URL');
request.setHttpMethod('GET'); // or POST, PUT, DELETE based on your requirement

// Setting up headers
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Authorization', 'Bearer YOUR_API_KEY');

// If it's a POST or PUT request, you might want to set the request body as well
// request.setRequestBody('YOUR_REQUEST_BODY_IN_JSON');

var response = request.execute(); // Sending the request

var httpResponseStatus = response.getStatusCode(); // Getting the status code
var httpResponseContentType = response.getHeader('Content-Type'); // Getting the content type
var httpResponseObj = response.getBody(); // Getting the response body

gs.info('HTTP Status Code: ' + httpResponseStatus);
gs.info('HTTP Content-Type: ' + httpResponseContentType);
gs.info('HTTP Response Object: ' + httpResponseObj);

 

 

You can watch the below video or help in O auth authentication with the API key and endpoint. 

https://www.youtube.com/watch?v=HlSAyeF0SVg

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma