GET request works with REST Client, but request from Node server returns 400


#1

Hello,

My GET request is working fine when using a rest client:

https://api.twitter.com/1.1/users/show.json?screen_name=chrisryanphd
Host: api.twitter.com
User-Agent: myApp
Authorization: Bearer ********
Accept-Encoding: gzip

However, when making the same request from within a Node Server, I’m getting a 400 response. Can anyone tell me what is going on? Thanks.

var rest = require('restler');
var userInfoURL = 'https://api.twitter.com/1.1/users/show.json?screen_name=';
var headers = {
  User-Agent: 'myApp',
  Authorization: 'Bearer ********',
  Host: 'api.twitter.com',
  Accept-Encoding: 'gzip'
};
/* ******************* */

exports.getUserInfo = function(lookupObject) { //object will have either a screenName or id as key and the corresponding value

  if ( lookupObject.screenName )  {
    //make api call using screen_name

    rest.get(userInfoURL + lookupObject.screenName , headers)
    .on('complete',function(data,response){
      if ( response.statusCode === 200 ) {
        console.log("data from the twitter", data);
      } else {
        console.log (response);
      }
    }); 
} else  // more code