How to call OUTBOUND REST Message in an UI Action. FYI: This integration is inside a scoped application & authentication type is 'oauth2'.

suchi
Giga Contributor

How to call OUTBOUND REST POST Message in an UI Action.

FYI: This integration is inside a scoped application & authentication type is 'oauth2'.

Requirement: On create Button Click REST POST Message should trigger & after success values to be set in Form from response values.

I already tried using Preview Script Usage from REST POST Message in UI Action, but it's not working.

try { 
var r = new sn_ws.RESTMessageV2('Testxxxxxxxx', 'post');
r.setAuthenticationProfile('oauth2', profile name);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
} catch(ex) {
var message = ex.message;
}
5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@suchi 

Please find points below

1) REST OUTBOUND call is inside a scoped application. Is this matter?

- Using REST Message V2 should be fine in Scoped application as well

Scripting outbound REST

REST Message v2

2) Authentication Type as mentioned "oauth2", which is token based. So how to do the same in this. Can you please share some sample code to embed REST OUTBOUND POST Method with the above authentication in place to make an asynchronous call.

- You need to setup OAuth Profile and enter all the details and then associate this OAuth profile to your REST Message when you create

Configure a REST message with OAuth

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader