Forum Discussion

mhashemi's avatar
2 years ago

Trouble Authenticating to LogicMonitor REST API from ServiceNow

I am trying to convert a PowerShell script to run from ServiceNow and found “Using REST API from ServiceNow Scripting” from two years ago. Since then, ServiceNow has added GlideDigest() which, among ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Why not use the Postman pre-request script? It’s already in javascript (this one is modified from that one to do just what you were wanting):

    var http_verb = "GET";
    var resource_path = "/device/devices";
    var epoch = (new Date()).getTime();
    var request_vars = (http_verb == 'GET'||http_verb == 'DELETE') ? http_verb + epoch + resource_path : http_verb + epoch + request.data + resource_path;
    var signature = btoa(CryptoJS.HmacSHA256("API_KEY").toString());
    var auth = "LMv1 " + "API_ID" + ":" + signature + ":" + epoch;
    return auth;