MrJonesIsMe
MrJonesIsMe

Reputation: 39

Instagram API Subscription endpoint asks for access token even though it is provided

I am sending a POST request to the Instagram API subscriptions endpoint to add a user subscription, but am getting the error:

error: StatusCodeError: 400 - {"meta": {"code":400, "error_type":"OAuthParameterException", "error_message":"Missing client_id or access_token URL parameter."}}

I have provided both the client_id and the access_token in my request.

Here is the request code.

let access_token = user[0].access_token
let options = {
        method: 'POST',
        uri: `https://api.instagram.com/v1/subscriptions/`,
        body: {
          access_token: access_token,
          client_id: instaConfig.client_id,
          client_secret: instaConfig.client_secret,
          object: 'user',
          aspect: 'media',
          verify_token: 'myVerifyToken',
          callback_url: `${callback_url}`
        },
        headers: {
          'User-Agent': 'Request-Promise'
        },
        // Automatically parses the JSON string in the response
        json: true
      }
// rp = require('request-promise')
      rp(options)
        .then((response) => {
          console.log('subscriptions response: ' + util.inspect(response, { showHidden: true, depth: null }))
        })
        .catch((err) => {
          console.log('error: ' + err)
        })

Upvotes: 0

Views: 181

Answers (1)

enator
enator

Reputation: 2599

It wouldn't read from body. It needs to be passed from query param or headers.

Upvotes: 1

Related Questions