How to send with rest message a form-urlencoded body?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:04 AM
Hi, how can I send these values via rest message? key: client_id, value: 1234 ||
key: client_secret, value: 5678?
I'm trying to do this via a fix script in servicenow:
var r = new sn_ws.RESTMessageV2('rest goSign token', 'GETTOKEN');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
if (httpStatus === 200) {
gs.info('http status: ' + httpStatus);
gs.info('token: ' + responseBody);
} else {
gs.info('Error Assertion: ' + responseBody);
gs.error(' http status: ' + httpStatus);
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 06:54 AM
Please try below -
var r = new sn_ws.RESTMessageV2('rest goSign token', 'GETTOKEN');
r.setAuthentication('basic', '1234', '5678'); // Replace '1234' and '5678' with your actual client_id and client_secret values
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
if (httpStatus === 200) {
gs.info('http status: ' + httpStatus);
gs.info('token: ' + responseBody);
} else {
gs.info('Error Assertion: ' + responseBody);
gs.error('http status: ' + httpStatus);
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar
