- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2017 10:44 PM
Hi ,
I am getting the response when i use curl command
curl -H 'Accept: application/json' -H 'Content-Type:application/json' -XGET https://someapi.example -H 'authorization:token' , for this I am getting the response.
But when i use it in javascript as following,
var r = new RESTMessage('https://someapi.example', 'get');
r.setStringParameter('token', 'token');
var response = r.execute();
var jsonString = response.getBody();
var parser = new JSONParser();
var parsed = parser.parse(jsonString);
getting error as:org.mozilla.javascript.EcmaError: Cannot convert null to an object.
am i missing anything?
The response here is null.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-15-2017 02:14 AM
Hey,
This worked for me,
var requestBody;
gs.print("start");
var responseBody;
var status;
var sm;
try{
sm = new sn_ws.RESTMessageV2("test", "get");
gs.print("start1");
sm.setRequestHeader("Authorization","token-string");
response = sm.execute();
gs.print("start2");
var jsonString = response.getBody();
Thank you all for your response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2017 10:53 PM
how are you getting token?
have you used getToken()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2017 11:01 PM
No i have the token , which is working with curl command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2017 11:05 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2017 11:09 PM
var rm = new sn_ws.RESTMessageV2("'https://someapi.example","get");
rm.setStringParameter('token', 'token');
rm.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
rm.setRequestBody(JSON.stringify({ "task": "new task2"}));
var response = rm.execute();
var responseBody = response.getBody();
getting error -REST Msg Outbound - RESTMessageClient : Error constructing REST Message/Method: 'https://someapi.example/get: com.glide.generators.InvalidGlideRecordException: Unable to find REST Message Record with Name: 'https://someapi.example: com.glide.rest.outbound.RESTMessageDAO.getRestMessageRecord(RESTMessageDAO.java:86)
