Using oauth2 in Recordless RESTMessageV2- POST

Arti Kumar
Tera Contributor

I'm trying to connect to  third party API via business rule. The third party endpoint URL and oauth details work perfectly fine when used in an outbound REST message and I see a 'Authorization=Bearer xxx' in the request (xxx being the token). Getting 200 success!

 

The same action when written in a business rule via Recordless RESTMessageV2 does not add the token in the request. I see a Authorization=null instead and get 'Invalid oauth' in response. How to get Oauth token programatically added to the request?

 

var restMessage = new sn_ws.RESTMessageV2();
restMessage.setAuthenticationProfile('oauth2', 'sys_id of the profile');
restMessage.setHttpMethod("post");
restMessage.setEndpoint("3rd party endpoint");
restMessage.setRequestBody("{\"short_description\" : \"Test incident\"}");
var response = restMessage.execute();

 

third party 

1 REPLY 1