- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 08-03-2022 04:57 AM
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
- 3,073 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hello Skk,
Following URLs should be helpful:
Enable tiny URL support (servicenow.com)
Constructing Tiny URLs - Now Platform - Question - ServiceNow Community
Mark this comment as Correct/Helpful so that other can also refer.
Regards,
Shubham
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi, is it a question or guidance how to shorten URL?
I executed the script but it returned to me exactly the same body.url (that was supposed to be shortened).
Hope it helps
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi, I passed URL of the 3k length (above 1024 allowed symbols), script returned to me the same 3k URL + sysparm_tiny attribute&value at the end. Is it how it is supposed to be? I assumed tiny API is supposed to shorten URL rather than extend it, no?
Hope it helps