Hello,
I am trying to download surveys from Qualtrics and have been able to connect to the API using my token and base URL (I'm guessing this on the basis of all_surveys() working with no errors).
However, the fetch_surveys does not seem to be working for me when trying to download any surveys. I get this error message:
> survey1 <- fetch_survey(surveyID = "SV_XXXX") ##Tried both copying survey id from the main Qualtrics IDs page as well as in the format of surveys$id[x]
Error in `qualtrics_response_codes()`:
! Qualtrics API reported a bad request error (400):
• Please report this on https://github.com/ropensci/qualtRics/issues
Running rlang::last_trace(drop = FALSE) gives me the following:
Backtrace:
▆
1. └─qualtRics::fetch_survey(surveyID = "SV_XXX")
2. └─qualtRics:::export_responses_request(...)
3. └─qualtRics:::export_responses_init(surveyID = surveyID, body = body)
4. └─qualtRics:::qualtrics_api_request(...)
5. └─qualtRics:::qualtrics_response_codes(res)
6. └─rlang::abort(error_message)
I have been going over some of the previously closed issues with similar error messages and have tried all the alternatives I can find.
- I am the owner of these surveys so that shouldn't be an issue. I am able to download/export surveys via Qualtric's web interface easily.
- My base URL is correct as far as I can see, and I have tried both formats of organizationID.datacenterID.qualtrics.com and datacenterID.qualtrics.com when registering credentials (with no https:// in the beginning).
- I re-generated my API token just in case that was the problem somehow but nope.
- Running the reprex function with the fetch_surveys gives me the same error message as above:
library(qualtRics)
#> Warning: package 'qualtRics' was built under R version 4.4.3
survey1 <- fetch_survey(surveyID = "SV_XXX")
#> Error in `qualtrics_response_codes()`:
#> ! Qualtrics API reported a bad request error (400):
#> • Please report this on https://github.com/ropensci/qualtRics/issues
- Running the code below also gave me $httpsStatus "200 - OK"
fetch_url <- qualtRics::generate_url(query = "fetchsurvey", surveyID = "SV_XXX")
raw_payload <- qualtRics:::create_raw_payload(
label = TRUE,
start_date = NULL,
end_date = NULL,
limit = NULL,
time_zone = NULL,
unanswer_recode = NULL,
unanswer_recode_multi = NULL,
include_display_order = TRUE,
include_questions = NULL,
breakout_sets = NULL
)
res <- qualtRics:::qualtrics_api_request("POST", url = fetch_url, body = raw_payload)
res$meta
- In case I was getting proxied, I also ran the curl code in command prompt and got this:
C:\Users\MarriumM>curl --request GET \ --url https://organizationID.ca1.qualtrics.com/API/v3/whoami \ --header 'x-api-token: XXXXXXX'
curl: (3) URL rejected: Bad hostname
{"meta":{"httpStatus":"400 - Bad Request","error":{"errorMessage":"Expected authorization in headers, but none provided.","errorCode":"ATP_2"},"requestId":"7b76c415-69b1-4aad-8b6f-686a60f05d92"}}curl: (3) URL rejected: Bad hostname
curl: (3) URL rejected: Bad hostname
I Googled this and got another format of this command to try and got this as a result, which I am assuming means things are okay on this end and my request is not getting proxied?
-H "X-API-TOKEN: XXXXX" -H "Content-Type: application/json" -X GET "https://datacenterID.qualtrics.com/API/v3/whoami
{"result":{"brandId":"XX"
,"userId":"XX",
"userName":"XX",
"accountType":"XX",
"firstName":"X",
"lastName":"X",
"email":"X",
"datacenter":"viawest"},
"meta":{"requestId":"2ed8adf8-f84c-45d6-bde4-48a227236063"
,"httpStatus":"200 - OK"}}
I've tried figuring out what else could possibly be wrong but I have hit a wall at this point! Can you tell me why this is happening and/or what can I do to fix this?
I am a beginner to coding (and R!) so I am afraid I don't understand most of this other than what my searches on Google provide and so I apologize if there any obvious things I missed!
Hello,
I am trying to download surveys from Qualtrics and have been able to connect to the API using my token and base URL (I'm guessing this on the basis of all_surveys() working with no errors).
However, the fetch_surveys does not seem to be working for me when trying to download any surveys. I get this error message:
Running rlang::last_trace(drop = FALSE) gives me the following:
I have been going over some of the previously closed issues with similar error messages and have tried all the alternatives I can find.
I Googled this and got another format of this command to try and got this as a result, which I am assuming means things are okay on this end and my request is not getting proxied?
I've tried figuring out what else could possibly be wrong but I have hit a wall at this point! Can you tell me why this is happening and/or what can I do to fix this?
I am a beginner to coding (and R!) so I am afraid I don't understand most of this other than what my searches on Google provide and so I apologize if there any obvious things I missed!