This a new code
uploadimage: function (img, callback) {
var fs = require(‘fs’);
var b64content = fs.readFileSync(‘img/farobot4.gif’, { encoding: ‘base64’ })
var request_options = {
url: 'https://upload.twitter.com/1.1/media/upload.json',
oauth: twitter_oauth,
//json: true,
headers: {
// 'content-type': 'application/x-www-form-urlencoded',
'content-type':'multipart/form-data'
// 'Content-Transfer-Encoding': 'base64'
},
//'media': b64content,
// 'media_data': b64content
media_data: b64content
}
request.post(request_options, function (error, response, body) {
if (error) {
console.log('Error creating welcome message.')
console.log(error)
return
}
callback(null, { 'base64': body });
})
An I get the following error:
{“errors”:[{“code”:214,“message”:“Bad request.”}]