Kerberos authentication for REST API call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2024 10:39 PM
I am developing an integration of ServiceNow with a third party system for which I need to make a REST API call from Servicenow using mid server to the third party system. I want help in this as mid server uses a proid which has kerberos prestashed tokens. I want to know what details do I need to mention for kerberos authentication in my script like principal, token etc. I dont know this and stuck here. Below is my script (but it does not have any mention of authentication, so what do I need to add for kerberos to work or do the mid server will do authentication by itself?):
var requestBody;
var responseBody;
var status;
var sm;
try{
sm = new sn_ws.RESTMessageV2(); // Might throw exception if message doesn't exist or not visible due to scope.
sm.setEndpoint("http://xyz.aa.com/authorize");
sm.setHttpMethod("get");
sm.setRequestBody("{\"user\" : \"abc\",\"action\" : \"approve\",\"eonid\" : \"71011\",\"component\" : \"change\"}");
sm.setLogLevel('all');
sm.setRequestHeader("Accept","Application/json");
sm.setEccParameter('skip_sensor', true);
sm.setMIDServer('mscore_1');
response = sm.executeAsync();
response.waitForResponse(60);
responseBody = response.haveError() ? response.getErrorMessage() : response.getBody();
status = response.getStatusCode();
} catch(ex) {
responseBody = ex.getMessage();
status = '500';
} finally {
requestBody = sm ? sm.getRequestBody():null;
}
gs.info("Request Body: " + requestBody);
gs.info("Response: " + responseBody);
gs.info("HTTP Status: " + status);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 05:57 AM
Hi,
This is something you have to find out from the 3rd party provider who is providing you API. Ask them for sample request, response and the authentication method that you have to use. Bsed on that you can create the relevant request in ServiceNow.
I am not sure why you are using a script. You can go to outbound->Restmessage and create new request. Select the authentication mechanism, define end poijnts, and can create requests. You can also select the midserver in the request.
Hope this helps you to lead to the solution. If yes, kindly accept the answer and click helpful.