ropensci / qualtRics

Download ā¬‡ļø Qualtrics survey data directly into R!
https://docs.ropensci.org/qualtRics
Other
215 stars 70 forks source link

fetch_survey produces "Error: Qualtrics API raised a bad request (400) error" #234

Closed avi-kluger closed 3 years ago

avi-kluger commented 3 years ago

Both of the following attempts to use the function (reading with API and reading from local file fail:

x <- fetch_survey("SV_3ecZ9vrQsiow5QG", force_request = TRUE, include_display_order = FALSE)

Error: Qualtrics API complains that the requested resource cannot be found (404 error). Please check if you are using the correct survey ID. Run rlang::last_error() to see where the error occurred.

x <- fetch_survey( "Incivility in health organizations_October 7, 2021_04.32.csv")

Error: Qualtrics API raised a bad request (400) error - Please report this on https://github.com/ropensci/qualtRics/issues Run rlang::last_error() to see where the error occurred.

<error/rlang_error> Qualtrics API raised a bad request (400) error - Please report this on https://github.com/ropensci/qualtRics/issues Backtrace:

  1. qualtRics::fetch_survey("Incivility in health organizations_October 7, 2021_04.32.csv")
  2. qualtRics:::qualtrics_api_request("POST", url = fetch_url, body = raw_payload)
  3. qualtRics:::qualtrics_response_codes(res)
juliasilge commented 3 years ago

The function fetch_survey() does not work on CSV files that you have downloaded. For those kinds of files, try out using read_survey()

For your problems fetching a survey by ID, is this possibly the same issue as #173, #177, #179, #184, and #193? Be sure your base URL is saved correctly as specified in the docs.

Notice that when you register your credentials:

The base URL you pass to the qualtRics package should either look like yourdatacenterid.qualtrics.com or like yourorganizationid.yourdatacenterid.qualtrics.com, without a scheme such as https://

avi-kluger commented 3 years ago

July,

The read_survey() was a stupid error. The other error was more subtle. I was using a survey that was shared with me by a user from different datacenter. When I queried their API directly I got

Error: Qualtrics API raised an forbidden (403) error - you may have a valid API key that lacks permissions to query the API. Please check your settings and/or talk to your administrators.

So, I presume that that cause my error.

Best,

Avi

From: Julia Silge @.> Sent: Thursday, October 7, 2021 7:27 PM To: ropensci/qualtRics @.> Cc: Avraham N Kluger @.>; Author @.> Subject: Re: [ropensci/qualtRics] fetch_survey produces "Error: Qualtrics API raised a bad request (400) error" (#234)

The function fetch_survey() does not work on CSV files that you have downloaded. For those kinds of files, try out using read_survey()https://docs.ropensci.org/qualtRics/reference/read_survey.html

For your problems fetching a survey by ID, is this possibly the same issue as #173https://github.com/ropensci/qualtRics/issues/173, #177https://github.com/ropensci/qualtRics/issues/177, #179https://github.com/ropensci/qualtRics/issues/179, #184https://github.com/ropensci/qualtRics/issues/184, and #193https://github.com/ropensci/qualtRics/issues/193? Be sure your base URL is saved correctly as specified in the docs.

Notice that when you register your credentialshttps://docs.ropensci.org/qualtRics/#register-your-qualtrics-credentials:

The base URL you pass to the qualtRics package should either look like yourdatacenterid.qualtrics.com or like yourorganizationid.yourdatacenterid.qualtrics.com, without a scheme such as https://

ā€” You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/ropensci/qualtRics/issues/234#issuecomment-937957763, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AB5WDQBDFBTARAKBVRDHY3TUFXC4VANCNFSM5FQ6XXHA. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

juliasilge commented 3 years ago

Yes, that would do it! Let us know if you have further problems. šŸ™Œ

axdey commented 2 years ago

Hi Julia and Avi,

I am getting a 403 error similar to the one that avi described when I try to fetch all surveys surveys<-all_surveys(). Here is the error message that I am getting:

Error in qualtrics_response_codes(res) : Qualtrics API raised an forbidden (403) error - you may have a valid API key that lacks permissions to query the API. Please check your settings and/or talk to your administrators.

Does this mean that the issue is with my API key? It was working fine for me till last weekend and suddenly stopped working.

Thank you,

Arnab

juliasilge commented 2 years ago

Hello there @arnabkdey! It is possible, yes. I'd suggest you see if you can generate a new API key for your account. If that doesn't work, I'd suggest that you open a new issue outlining your problem instead of posting under an old, closed issue. šŸ‘