Shortening any URL of ServiceNow by using API
var request = new sn_ws.RESTMessageV2();
request.setEndpoint('https://devxxxxxx.service-now.com/api/now/tinyurl'); //change that devxxxxx to your instance domain
request.setHttpMethod('POST');
//Eg. UserName="admin", Password="admin" for this code sample.
var user = ‘id’;
var password = 'password’; // you can create a user with no roles also we just need some ServiceNow instance user
var body={};
body.url='https://devxxxx.service-now.com/sys\_user.do?sys\_id=6841a85a2f095110c083d0ccf699b6e8&sysparm\_view=&sysparm\_domain=null&sysparm\_domain\_scope=null'; //url that need to be shortened
request.setBasicAuth(user, password);
request.setRequestHeader("Accept", "application/json");
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestBody(JSON.stringify(body));
var response = request.execute();
gs.info(response.getBody()); // you will get JSON of url
https://www.servicenow.com/community/developer-articles/shortening-any-url-of-servicenow-by-using-api/ta-p/2305210