Media Upload with API 1.1


I’m using:

Twitter REST API 1.1 /media/upload
npm node-twitter
Client Side: angular.js (not relevant to the example am posting below)

I guess ‘node-twitter’ uses base URL as but for media upload the base URL is - am not 100% sure about how ‘node-twitter’ package handles all these. But after working with it for sometime I feel it’s REST API base URL is set as

router.get('/api/media/upload', function(req, res){
    var fs = require('fs');'/media/upload', {media: fs.readFileSync('C:/Users/Satish/Downloads/243515_183060768410422_4955904_o.jpg', { encoding: 'base64' })}, function(error, params, response){
            if(error) console.log(error);
            else {
 '/statuses/update', {status: 'hello world!', media_ids: [params.media_id]}, function(error, params, response){

But this code is throughing error, stating - 404, page does not exist. My guess is, ‘node-twitter’ is considering as base URL for /media/upload too. If I replace ‘/media/upload’ with full URL ‘’ still I get the same error message :frowning:

[Most of the articles online are written for deprecated POST statuses/update_with_media ]


I had a quick look to the source code and it seem they handle it properly:

// If the path begins with media or /media
    if (path.match(/^(\/)?media/)) {
      endpoint =;

I can’t find any obvious error in your code, I think it should work…