ropensci / qualtRics

Download ⬇️ Qualtrics survey data directly into R!
https://docs.ropensci.org/qualtRics
Other
215 stars 70 forks source link

url error with fetch_survey() but not with all_surveys() #288

Closed bjsmith closed 2 years ago

bjsmith commented 2 years ago

I am getting a curl url error occurring with fetch_survey() but not with all_surveys().

First I load my credentials:

credentials <- yaml::read_yaml(cred_file_location)

qualtrics_api_credentials(api_key = credentials$token, base_url=credentials$baseurl, install=FALSE)

Then I try to access the survey. I get surveys come back.

> surveysAvail = all_surveys()
> nrow(surveysAvail)
[1] 59

On inspection, the data looks great. So all good to go, right?

> fetch_survey(surveyID=surveysAvail[[59,"name"]])
Error in curl::curl_fetch_memory(url, handle = handle) : 
  URL using bad/illegal format or missing URL

I have tried this with entering in the survey's name rather than referring to a cell in the the surveysAvail dataframe. No difference.

It's odd to see that the baseurl and credentials work for retrieving surveys, but there is a URL error for fetch_survey.

Any suggested fixes?

bjsmith commented 2 years ago

update: encoding the URL with URLencode changes the problem, and you get the error:

Error in `qualtrics_response_codes()`:
! 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.
kevintroy commented 2 years ago

Hi Ben, fetch_survey is expecting the survey ID, not its name. It should be a string starting with "SV_" followed by a unique alphanumeric ID.

This code should work: fetch_survey(surveyID=surveysAvail[[59,"id"]])

bjsmith commented 2 years ago

The mistake mine--using the survey ID instead of the survey name. My mistake. survey ID is correctly documented as the value to use.

bjsmith commented 2 years ago

just saw your comment as I commented. Thanks @kevintroy