How to store Rest API Endpoint url , method and Authentication Key and values in system property ? how can we call this property in scheduled jobs/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-05-2022 11:22 PM
How to store Rest API Endpoint url , method and Authentication Key and values in system property ? how can we call this property in scheduled jobs.
can you please share examples. Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-06-2022 05:04 AM
var Endpoint_url = gs.getProperty('EamLinuxUrl');
var API0 = gs.getProperty('X-API-KEY');
var API1 = gs.getProperty('X_API_USER');
var API2 = gs.getProperty('X_API_USER_KEY');
try {
var r = new sn_ws.RESTMessageV2();
r.setEndpoint('Endpoint_url')
r.setHttpMethod('GET');
r.BasicAuth('API_KEY1', API0);
r.BasicAuth('API_KEY2', API1);
r.BasicAuth('API_KEY3', API2);
var response = r.execute();
var httpStatus = response.getStatusCode();
var responseBody = response.getBody();
}
catch(ex)
{
var message = ex.message;
}
i used the same script above you mentioned but it is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-09-2022 12:54 AM
What error do you receive ? Can you check the logs and send them back ?
Check System Logs -> Outbound HTTP Requests
You should be able to see the results there
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-09-2022 02:52 AM
var Endpoint = gs.getProperty('Url');
var API0 = gs.getProperty('KEY0');
var API1 = gs.getProperty('key1');
var API2= gs.getProperty('key2');
try {
var r = new sn_ws.RESTMessageV2();
r.setEndpoint( Endpoint);
r.setHttpMethod('GET');
r.setRequestHeader('API-KEY',API0);
r.setRequestHeader('API_USER', API1);
r.setRequestHeader('API_USER_KEY' , API2);
var response = r.execute();
var httpStatus = response.getStatusCode();
var responseBody = response.getBody();
The above code is now working
Thank all for your inputs.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-11-2022 01:45 AM
Great to hear that, feel free to mark our answers as helpful if they were indeed helpful.
Thanks.
Ed`N