0

I'm trying to make a post request to an endpoint of the instagram api (https://api.instagram.com/oauth/access_token).

Here is what I'm doing:

const requestOptions = {
  method: 'POST',
  body: JSON.stringify({
    client_id: APP_ID,
    client_secret: APP_SECRET,
    code,
    grant_type: "authorization_code",
    redirect_uri: REDIRECT_URI
  })
};

fetch("https://api.instagram.com/oauth/access_token", requestOptions)
  .then(r => r.json())
  .then(r => console.log(r))

APP_ID, APP_SECRET & REDIRECT_URI aren't null (I can see them in the request payload)

Request payload

However I still get a 400 error saying: "Missing required field client_id"

Any thoughts on this? Thanks

Phil
  • 157,677
  • 23
  • 242
  • 245
  • try with postman, still getting the error? – Ger Aug 05 '21 at 23:38
  • You need `header: { "Content-type": "application/json" }` to post JSON but I think the [Instagram API](https://developers.facebook.com/docs/instagram-basic-display-api/reference/oauth-access-token/) is expecting `application/x-www-form-urlencoded` – Phil Aug 05 '21 at 23:47
  • Sorry, that should have been `headers` but in any case, it's not applicable for what you're trying to do – Phil Aug 05 '21 at 23:57

0 Answers0