jeepers mcface
jeepers mcface

Reputation: 419

Why am I getting a 403 error response with my SurveyMonkey API get request?

I have attempted to follow the SurveyMonkey API documentation to a tee, just to get familiar with it before I move into the very simple functionality of my private application.

I have pretty much attempted to duplicate exactly what I've found in the documentation, but am getting a 403 response. You can see the exact snipped of code here in the docs: https://api.surveymonkey.net/v3/docs?python#surveys-id

api_token = 'MyVerySecretApiKey'

survey_id = 'ASillyLittleNumber'


s.headers.update ({
    "Authorization": "Bearer %s" % api_token,
    "Content-Type": "application/json"
})

HOST = "https://api.surveymonkey.com/v3/surveys/%s" % (survey_id)

print s.get(HOST)

I've printed the GET just to see what exactly I'm getting, and I'm getting Response [403]. I can't figure out what I've done, especially with such a simple application. I've checked my api token and the survey id several time for accuracy. Is there anything I'm not understanding about the code from the documentation?

I've passed my api key and survey id as strings, and that's correct right?

Upvotes: 1

Views: 1849

Answers (1)

Danielle M.
Danielle M.

Reputation: 3662

Your code looks fine - the requests module will take care of integers / strings in your headers, no need to worry about that.

The only thing I can think of is that maybe you're confusing your API key with your bearer token - based on this line:

api_token = 'MyVerySecretApiKey'

Check the settings page on your SM dev page and see if you can generate a bearer token for your account, and if it differes from the API key.

Upvotes: 0

Related Questions