Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qualtrics API reported a bad request error (400) #339

Open
ktmorris opened this issue Feb 8, 2024 · 2 comments
Open

Qualtrics API reported a bad request error (400) #339

ktmorris opened this issue Feb 8, 2024 · 2 comments

Comments

@ktmorris
Copy link

ktmorris commented Feb 8, 2024

While the all_surveys() function is working fine, fetch_survey() throws the following error:

` l <- fetch_survey(surveys$id[2])

Error in qualtrics_response_codes():

! Qualtrics API reported a bad request error (400):

• Please report this on https://github.com/ropensci/qualtRics/issues

Run rlang::last_trace() to see where the error occurred.`

@juliasilge
Copy link
Collaborator

Hello @ktmorris! There are two common issues that cause folks to run into this error.

The base URL you pass to the qualtRics package should either look like yourdatacenterid.qualtrics.com or like yourorganizationid.yourdatacenterid.qualtrics.com

  • The second is Qualtrics proxying your request. Do you see any messages about this? For example, what do you see when you run this at the command line (not in R)?
curl --request GET \
--url https://XXX.qualtrics.com/API/v3/whoami \
--header 'x-api-token: YOURLONGAPITOKENHERE'

You would need to use your URL and your API token. Do you see anything in the results like:

Notice: Request proxied. For faster response times, use this host instead:

  • Another thing to try -- can you run this code to see a bit more detail about what is happening?
## put your survey ID here:
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
#> $requestId
#> [1] "f52b2929-b24a-4c9d-88a6-e7c9d3ff660d"
#> 
#> $httpStatus
#> [1] "200 - OK"

Created on 2022-04-04 by the reprex package (v2.0.1)

@higgi13425
Copy link

Similar issue - request was proxied. Once I used the other URL, all went well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants