- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 09:29 PM
Hello,
I am very new in the web service.
I want to access a third party URL and retrieve data in json format using get method.
I have created a REST message and using get method am expecting a json format but not coming as [],but status is 200.
What the step am missing here or how can make it working
Solved! Go to Solution.
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 11:06 PM
Hi Saranya,
The status of 200 means a success. The response you should be able to get in logs using the below script
var r = new sn_ws.RESTMessageV2('getCartoon Number', 'get');
// set various parameters which you want
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log(JSON.stringify(responseBody));
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 11:06 PM
Hi Saranya,
The status of 200 means a success. The response you should be able to get in logs using the below script
var r = new sn_ws.RESTMessageV2('getCartoon Number', 'get');
// set various parameters which you want
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log(JSON.stringify(responseBody));
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 11:15 PM
Hello ankur,
Tried in background script and getting null
*** Script: null
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 11:28 PM
Hello Ankur,
I tried the below script
try {
var r = new sn_ws.RESTMessageV2('getCarton Number', 'get');
r.setStringParameter('olpn', 'DTR000628859');
//override authentication profile
//authentication type ='basic'/ 'oauth2'
//r.setAuthentication(authentication type, profile name);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log('http response status_code: '+httpStatus);
gs.log('http response responseBody: '+responseBody);
}
catch(ex) {
var message = ex.getMessage();
}
*** Script: http response status_code: 200
*** Script: http response responseBody: []
Does it will the issue in endpoint url/external server?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-16-2017 11:38 PM
Hi Saranya,
Since you are setting the parameter "olpn" and you have hardcoded the olpn number in the endpoint it might not be able to get the value for that olpn number in that system.
Have this in endpoint olpn=${olpn} and in the variable substitutions create a variable and have following in name and test value olpn and then test
This will have a dynamic value for olpn
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader