Outbound Rest Message using get method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2017 11:36 PM
Hello,
I have used below background script to test the functionality and getting the below error.
What need to be checked from the endpoint url?
(function sample_http_request() {
try {
var request = new sn_ws.RESTMessageV2();
request.setHttpMethod('get');
request.setEndpoint('http://localhost:8080/xxx?id=1234');
var response = request.execute();
var httpResponseStatus = response.getStatusCode();
var httpResponseContentType = response.getHeader('Content-Type');
var parser = new global.JSONParser();
var parsed = {};
var httpResponseBody;
gs.debug("http response status_code: " + httpResponseStatus);
gs.debug("http response content-type: " + httpResponseContentType);
// if request is successful then parse the response body
if (httpResponseStatus == 200 && httpResponseContentType == 'application/json') {
httpResponseBody = response.getBody();
// parse JSON string returned from request into a json object
parsed = parser.parse(httpResponseBody);
// iterate over JSON object only printing the id property of JSON objects in results array
for (var i = 0; i < parsed.results.length; i++) {
gs.print('id: ' + parsed.results[i].id)
}
}
}
catch (ex) {
var message = ex.getMessage();
gs.debug(message);
}
})();
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2017 05:22 AM
Hi Saranya,
Changing to correct credentials does it work. Please reply back in case of issues.
Regards
Param
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2017 02:07 AM
Hi saranya s babu,
status_code==401 means, credentials issue
Please click helpful,correct answer,like
Thanks,
Raminaidu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2017 01:56 AM
Hi Saranya.
This must be authentication issue.
Thanks,
Swati