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

Cannot like a tweet with v2 #169

Open
orimdominic opened this issue May 23, 2021 · 3 comments
Open

Cannot like a tweet with v2 #169

orimdominic opened this issue May 23, 2021 · 3 comments
Labels

Comments

@orimdominic
Copy link

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?

@danh7598
Copy link

are you fixed it?

@orimdominic
Copy link
Author

@danh7598 I ended up using the library here node-twitter-api-v2

@danh7598
Copy link

thanks a lot, i'll try it

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

No branches or pull requests

3 participants