ropensci / qualtRics

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

error in qualtrics_response_codes(res) : Qualtrics API raised a bad request (400) error #184

Closed wongsl98 closed 4 years ago

wongsl98 commented 4 years ago

I got this error code:

error in qualtrics_response_codes(res) : Qualtrics API raised a bad request (400) error - Please report this on https://github.com/ropensci/qualtRics/issues

after the following code:

readRenviron("~/.Renviron") knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE)

library(tidyverse) library(pander) panderOptions('round', 2) panderOptions('keep.trailing.zeros', TRUE)

Raw Survey Data

df_raw <- read_csv("Risk_Strategy.csv")

df_raw <- qualtRics::fetch_survey(

  • surveyID = "xxx",
  • force_request = TRUE,
  • verbose = FALSE,
  • label = FALSE,
  • convert = FALSE
  • )

could you help me see what's wrong/what I should change? thank you

juliasilge commented 4 years ago

That sounds frustrating! To dig into this problem, we need you to use reprex so we can make sure the environment is clean, etc.

After you have that set up, try running this code:

library(qualtRics)
all_surveys()

Your output (what you paste here on GitHub) should look like this, but with your surveys (feel free to censor any PII that shows up):

library(qualtRics)
all_surveys()
#> # A tibble: 4 x 6
#>   id         name           ownerId     lastModified    creationDate    isActive
#>   <chr>      <chr>          <chr>       <chr>           <chr>           <lgl>   
#> 1 SV_3gbwq8… Beskar Armor   UR_8wfG5qs… 2020-02-20T01:… 2020-02-20T00:… TRUE    
#> 2 SV_56icaa… Cats Can Have… UR_8wfG5qs… 2020-06-10T23:… 2020-02-11T03:… TRUE    
#> 3 SV_5BJRo2… Sourdough Bre… UR_8wfG5qs… 2020-03-29T20:… 2020-03-29T20:… TRUE    
#> 4 SV_ezYI0F… Priorities fo… UR_8wfG5qs… 2020-05-06T19:… 2020-04-23T18:… TRUE

Created on 2020-07-25 by the reprex package (v0.3.0.9001)

If that works (i.e. you can see the surveys you should have access to), what happens if you try this with the survey ID, again using reprex?

library(qualtRics)
fetch_survey(surveyID = "SV_XXX") ## put your ID here
wongsl98 commented 4 years ago

hello, thanks for replying! yes I have used qualtrics_api_credentials() with install = TRUE to install my credentials to my .Renviron file.

ran reprex on all_surveys() and this is what I got:

``` r
library(qualtRics)
all_surveys()
#> Warning in check_for_warnings(cnt): Request proxied. For faster response times,
#> use this host instead: sjc1.qualtrics.com
#> Error in curl::curl_fetch_memory(url, handle = handle): Could not resolve host: devplat-gateway-shared.service.sjc1.consul

Created on 2020-07-27 by the reprex package (v0.3.0)

juliasilge commented 4 years ago

Check out #173, #177, and #179, and 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://

wongsl98 commented 4 years ago

Oh thank you for referring me to the other threads. I thought I had the base URL right but I guess not. everything works now, thank you so much!