twit
twit copied to clipboard
T.get('media/upload') with `command: 'STATUS'` returns `400 Bad Request`
I have the following code:
async function getUploadMediaStatus(T, { mediaData }) {
const { media_id_string } = mediaData;
return T.get('media/upload', {
command: 'STATUS',
media_id: media_id_string,
});
}
Invoked by:
const status = await getUploadMediaStatus(T, { mediaData });
The request completes but I get the following response:
> status
{ data: '', res: IncomingMessage }
Upon further probing, looks like the request failed:
> status.res.statusCode
400
> status.res.statusMessage
'Bad Request'
Looking at the Twit
docs, this should be the correct way to perform a T.get
.
I put debuggers
in the Twit
code and traced it to this line: https://github.com/ttezel/twit/blob/master/lib/twitter.js#L352
Looks like it was a success but the statusCode
is still 400
?
I was able to make a request manually using Postman
ping @ttezel
I've got the same issue.
The only way I've find to over pass the problem si to do a simple tweet post like
// Don't remove this. // If you remove this the bot doesn't work for mysterious reasons // he gona send a 187 error but don't care about this it's not important t.post('statuses/update', { status: 'hello world!' }, (err, data, response) => { console.log(data) })
And after you can post the picture with your function
This is realy weird but it's working fine for me
@pthieu the first time you gona use my function he will post a
hello world
But don't care and let it in your tweet lane and after he will work fine
@Quenntinne: Due to the architecture of my code, I don't need a long-running instance of a Twitter API client so I ended up using the twitter
package just to do the status call and destroying the instance when done.
This is a duplicate of https://github.com/ttezel/twit/issues/259