Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T.get('media/upload') with command: 'STATUS' returns 400 Bad Request #463

Open
pthieu opened this issue Sep 9, 2018 · 5 comments · May be fixed by #502
Open

T.get('media/upload') with command: 'STATUS' returns 400 Bad Request #463

pthieu opened this issue Sep 9, 2018 · 5 comments · May be fixed by #502

Comments

@pthieu
Copy link

pthieu commented Sep 9, 2018

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

@pthieu
Copy link
Author

pthieu commented Sep 9, 2018

ping @ttezel

@Quenntinne
Copy link

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

@Quenntinne
Copy link

@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

@pthieu
Copy link
Author

pthieu commented Sep 13, 2018

@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.

@patrickd-
Copy link

This is a duplicate of #259

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants