How to pass the value dynamically in REST messages endpoint
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 05:18 AM
instated of {topicName} I wanted to pass the value for example a1_topic. And using put method I need to pass the payload.
I tried with the below script
var oAuthClient = new sn_auth.GlideOAuthClient();
var params = {
'grant_type': 'client_credentials',
'client_id': 'MLW2',
'client_secret': 'gAA'
};
var json = new global.JSON();
var text = json.encode(params);
var tokenResponse = oAuthClient.requestToken('EDL ', text);
var token1 = tokenResponse.getToken();
var token = token1.getAccessToken();
// var tokenParsed = JSON.parse(token);
// var token2 = tokenParsed.token;
gs.print("update existing token" + token);
var topicName="a15_topic";
var restMessage = new sn_ws.RESTMessageV2();
restMessage.setStringParameterNoEscape("Token", token);
//restMessage.setAuthenticationProfile('oauth2', '43c1772e1b8ad9502fdb844467777');
restMessage.setHttpMethod("put");
restMessage.setEndpoint("https://api-dev.nametopic.com/data/v1/topics/{topicName}");
restMessage.setRequestBody("request_id","RITM1");
restMessage.setRequestBody("number","2");
var response = restMessage.execute();
gs.print("test" +response);
I am getting like this error
escaped absolute path not valid: java.lang.IllegalArgumentException: Invalid uri
Please any one look into this one.