Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Rest Message OUTBOUND

ican
Tera Contributor

Use Case:

I want to use Rest Message Endpoint with Parameters and HTTP Query Parameters:

 

Endpoint: https://test.com/${id}

 

HTTP Query Parameters:

api_username: testapiusername

api_key: testapikey

 

is this possible?

6 REPLIES 6

Community Alums
Not applicable

Hi @ican , 

Rest message will only work when you give appropriate EndPoint, HTTP Query Parameter. You can refer below code to call the Rest Message

var sm = new sn_ws.RESTMessageV2("<REST_message_record>","get"); 
var response = sm.execute();

 

Please mark my answer correct and helpful if this works for you

 

Thanks and Regards 

Sarthak

 

 

I already have a working outbound REST Message.

Endpoint: www.test.com

 

HTTP Query Parameters:

id: ${id}

api_username: testapiusername

api_key: testapikey

 

What I would like to do is put the ${id} in the endpoint.

 

Endpoint: www.test.com/${id}

 

HTTP Query Parameters:

api_username: testapiusername

api_key: testapikey

 

Currently its not working. im getting 403 error status saying api_username missing.

Community Alums
Not applicable

Hi @ican,

I tried your problem in my PDI, I got the solution may be this works for you! 

For example 

SarthakKashya2_1-1713339128483.png

You have the endpoint - https://${pushHost}/api/now/v1/push/${applicationName}/enqueue

 

Here you have the variable ${applicationName}, so in script include you need to give this parameter refer below code 

 var r = new sn_ws.RESTMessageV2('ServiceNowMobileApp Push', 'post');
r.setStringParameterNoEscape('applicationName', <Value>);
 var response = r.execute();
 var responseBody = response.getBody();
 var httpStatus = response.getStatusCode()

 

Please reach me out if you need anything. 

 

Please mark my answer correct and helpful if this works for you

Thanks and Regards 

Sarthak

 

 

 

I want to combine HTTP Query Params in REST Message and variable in the Endpoint.

 

When I combine them, it is not working for me.

But when i use either one, whether i put all variables in the Endpoint or all variables in the HTTP Query Params, it is working fine.