Skip to content

post method throw error  #364

Description

@maychine-fatima

after usign it with get, it worked but when i wanted to use it with an api with post methode it therows error
this is my code

`    const oauth = new OAuth.OAuth(
      "https://api.twitter.com/oauth/request_token",
      "https://api.twitter.com/oauth/access_token",
      TWITTER_CONSUMER_KEY,
      TWITTER_CONSUMER_SECRET,
      "1.0A",
      null,
      "HMAC-SHA1"
    );
    oauth.post(
      "https://api.twitter.com/2/tweets",
      TWITTER_ACCESS_TOKEN, //  user token
      TWITTER_SECRET_TOKEN, //  user secret
      { text: "hi" },
      "application/json",
      async function(e, data) {
        if (e) console.log(e);
        console.log(data);
      });`

it return this error
{
statusCode: 400,
data: '{"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"}'
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions