Rest Message OUTBOUND
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2024 03:39 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2024 03:47 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-16-2024 11:30 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 12:35 AM
Hi @ican,
I tried your problem in my PDI, I got the solution may be this works for you!
For example
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2024 12:52 AM
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.