0

(I am totally new to Restlet client and Server scripting)

I am trying to get JSON Data from response body of the Restlet client using below code but I could not get that

var http = require('http');
var options = {
  host: 'staging.api.pearson.com',
  port: 80,
  path: '/sc-api/apis/content/urn:pearson:manifestation:db7eac5b-8f65-49dc-97bc-d0f5e824f135'
};

http.get(options, function(res) {
  console.log("Got response: " + res.statusCode);

  res.on("data", function(chunk) {
    console.log("BODY: " + chunk);
  });
}).on('error', function(e) {
  console.log("Got error: " + e.message);
});

Getting the below output:

enter image description here

But when using the Restlet client GUI, can able download the response BODY Json

enter image description here

Adding Environments details:

enter image description here

Browser Snapshot:

enter image description here

Kindly anybody suggest any way to do

(I am totally new to Restlet client and Server scripting)

Thanks

2 Answers2

0

The only difference I see between your code and rest client GUI is the port. Is the host name a VIP? In that case, you shouldn't use port in your code. Also as others said, use https as you are using It in GUI.

Uday
  • 1,165
  • 9
  • 12
0

As said in the first comment, your URL is only accessible via https

I myself use the request.js package

Example:

var request = require('request');
var url = 'https://staging.api.pearson.com/sc-api/apis/content/urn:pearson:manifestation:db7eac5b-8f65-49dc-97bc-d0f5e824f135';

request.get(url,{},function(err,res,body){
  if(err) 
    console.log("Got error: " + e.message);
  else {
    console.log("Status: ", res.statusCode);
    console.log("body: ", body);
  }
});
  • getting : Status: 404 body: {"fault":{"faultstring":"Unable to identify proxy for host: apipearsoncom and url:\/sc-api\/apis\/content\/urn:pearson:manifestation:db7eac5b-8f65-49dc-97bc-d0f5e824f135","detail":{"errorcode":"messaging.adaptors.http.flow.Applicati onNotFound"}}} – Elambarathi Vimal Kannan Jun 06 '17 at 14:13
  • Kindly check the GUI screenshot, just now its updated – Elambarathi Vimal Kannan Jun 06 '17 at 14:22