ttezel / twit

Twitter API Client for node (REST & Streaming API)
4.31k stars 568 forks source link

Getting a 404 error when trying to favorite or create friendship #480

Closed slippyex closed 6 years ago

slippyex commented 6 years ago

Guys, when I want to either create a friendship or a favorite on a tweet (which I retweeted), I get a 404 "Error: Sorry, that page does not exist"

Do I need to change the format of my code line? Did Twitter API change internally?

await T.post('favorites/create/:id', {id: tweet.id_str}, {});

or

await T.post('/friendships/create/' + tweet.user.id_str)

whereas the following line works perfectly fine for me

await T.post('statuses/retweet/' + tweet.id_str, {});

slippyex commented 6 years ago

I digged into the above again and debugged it a bit ... it seems that the way to compose an url is pretty restrictive ... However, wanted to share my solution with you

await T.post('friendships/create', {user_id: userId, follow: true });

works perfectly fine now ... the internal query builder create an invalid url for my cases above. So take care that you don't put a trailing "/" to those urls because they will be turned into something like

https://api.twitter.com/1.1/friendships/create/.json?user_id={{THE_USER_ID_TO_FOLLOW}}&follow=true

That being said, I will close the issue ...