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












1















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?










share|improve this question



























    1















    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?










    share|improve this question

























      1












      1








      1








      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?










      share|improve this question














      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?







      python api python-requests surveymonkey






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 2 at 1:57









      jeepers mcfacejeepers mcface

      90110




      90110
























          1 Answer
          1






          active

          oldest

          votes


















          0














          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.






          share|improve this answer
























          • Ah, I figured it out. You got me going back into the settings for my dev account and I saw that you have to let the app have certain scopes via the dev portal (though I would imagine you could permit them in app). I got a 200 response, which I think is good... Just need to figure out how to display/download the info! Thanks!

            – jeepers mcface
            Jan 2 at 2:20











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000408%2fwhy-am-i-getting-a-403-error-response-with-my-surveymonkey-api-get-request%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          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.






          share|improve this answer
























          • Ah, I figured it out. You got me going back into the settings for my dev account and I saw that you have to let the app have certain scopes via the dev portal (though I would imagine you could permit them in app). I got a 200 response, which I think is good... Just need to figure out how to display/download the info! Thanks!

            – jeepers mcface
            Jan 2 at 2:20
















          0














          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.






          share|improve this answer
























          • Ah, I figured it out. You got me going back into the settings for my dev account and I saw that you have to let the app have certain scopes via the dev portal (though I would imagine you could permit them in app). I got a 200 response, which I think is good... Just need to figure out how to display/download the info! Thanks!

            – jeepers mcface
            Jan 2 at 2:20














          0












          0








          0







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 2 at 2:11









          Danielle M.Danielle M.

          1,9401523




          1,9401523













          • Ah, I figured it out. You got me going back into the settings for my dev account and I saw that you have to let the app have certain scopes via the dev portal (though I would imagine you could permit them in app). I got a 200 response, which I think is good... Just need to figure out how to display/download the info! Thanks!

            – jeepers mcface
            Jan 2 at 2:20



















          • Ah, I figured it out. You got me going back into the settings for my dev account and I saw that you have to let the app have certain scopes via the dev portal (though I would imagine you could permit them in app). I got a 200 response, which I think is good... Just need to figure out how to display/download the info! Thanks!

            – jeepers mcface
            Jan 2 at 2:20

















          Ah, I figured it out. You got me going back into the settings for my dev account and I saw that you have to let the app have certain scopes via the dev portal (though I would imagine you could permit them in app). I got a 200 response, which I think is good... Just need to figure out how to display/download the info! Thanks!

          – jeepers mcface
          Jan 2 at 2:20





          Ah, I figured it out. You got me going back into the settings for my dev account and I saw that you have to let the app have certain scopes via the dev portal (though I would imagine you could permit them in app). I got a 200 response, which I think is good... Just need to figure out how to display/download the info! Thanks!

          – jeepers mcface
          Jan 2 at 2:20




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000408%2fwhy-am-i-getting-a-403-error-response-with-my-surveymonkey-api-get-request%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith