Media_data/upload returns Status Code 400



I am trying to upload an image to twitter account using twitter’s media upload api. I am using node-twitter module for nodejs.

This is the code i am using

`var base64Image = data.image;‘media/upload’, { media_data: base64Image }, function (error, media_data, response) {
if (!error) {
// If successful, a media object will be returned.

                // Lets tweet it
                var status = {
                    status: 'Sample tweet'+ randomHashtag,
                    media_ids: media_data.media_id_string // Pass the media id string

      'statuses/update', status, function (error, tweet, response) {
                    if (!error) {

            else {

I have also tried these errors but its not working

app.use(function (req, res, next) { res.setHeader('Content-Type', 'multipart/form-data'); res.setHeader('Content-Type', 'application/octet-stream'); res.setHeader('Content-Transfer-Encoding',' base64'); next(); } );