The CreatorCon Call for Content is officially open! Get started here.

How to retrieve the REST web service endpoint details through script

LearnerSubho
Mega Guru

Dear All,

I would like to know about how to retrieve the REST web service endpoint details through script?

Suppose, the endpoint is set as https://XXXXX.service-now.com/api/now/v1/table/incident?sysparm_query=active%3Dtrue%5Epriority%3D1&s...

I want to retrieve the endpoint information from the web service and modify it.

Can anyone please help me out?

Thanks in advance,

Subhankar

3 REPLIES 3

tony_barratt
ServiceNow Employee
ServiceNow Employee

Hi Subhankar,



Not sure what your use case is but the REST Endpoint can be set like so:


SOAPMessageV2 - setEndpoint(String endpoint)



How/if   the current REST endpoint could be determined might depend on how the outbound REST was implemented.



Best Regards



Tony









Subhankar


Dear Tony,



Thank you for the response.



I am aware of how to set endpoint.



I want to know if there is any way to retrieve the already set endpoint..something equivalent to getEndpoint.



e.g. I want to change the table name of the already configured endpoint from script multiple times. So, I want to retrieve the configured endpoint, modify and reset.



Thanks,


Subhankar


amila
ServiceNow Employee
ServiceNow Employee

As I understand you need to get the endpoint within your script. One way is access that using GlideRecord api.



Rest message details are stored in a table called 'sys_rest_message'. you can query your end point using 'name' or 'sys_id' then get the end point using 'rest_endpoint'.



var gr = new GlideRecord('sys_rest_message');


gr.addQuery('name','Google Cloud Messaging Send');


gr.query();


gr.next();


gs.log(gr.getValue('rest_endpoint'));



rest method details are stored in sys_rest_message_fn table. Similarly you can take values of that table too.