Cannot like a tweet with v2
orimdominic opened this issue · comments
I don't know if this just is me or someone else is having this issue.
I created a client with the v2 properties
this.v2 = new Twitter({
extension: false,
version: "2",
consumer_key: process.env.TWITTER_CONSUMER_KEY,
consumer_secret: process.env.TWITTER_CONSUMER_SECRET,
access_token_key: process.env.TWITTER_ACCESS_TOKEN,
access_token_secret: TWITTER_ACCESS_TOKEN_SECRET
});
}
I tried to like a tweet using this method below
async likeTweet(id, userId) {
try {
const resp = await this.v2.post(
`users/${userId}/likes`,
{
tweet_id: id,
}
);
return resp;
} catch (error) {
console.error("twitterClient.likeTweet", JSON.stringify(error));
}
}
}
and I keep getting this error message from the Twitter API
{
"_headers":{},
"errors": [
{
"parameters":{},
"message":"Requests with bodies must have content-type of application/json."
}
],
"title": "Invalid Request","detail":"One or more parameters to your request was invalid.",
"type": "https://api.twitter.com/2/problems/invalid-request"
}
Is this from me or from the package?
How can this be resolved?
are you fixed it?
@danh7598 I ended up using the library here node-twitter-api-v2
thanks a lot, i'll try it