Closed grosasballina closed 3 years ago
That warning about the request being proxied is new to me, and I wonder if it is related. Can you use reprex to run code like this so I can get a better look at it?
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-09-22T19:… 2020-04-23T18:… TRUE
Created on 2021-04-06 by the reprex package (v2.0.0)
If there is any PII in the output, feel free to censor it with XXX or similar.
Another thing to check is to put the request together manually and see what is there. Set it up like this, but with your survey ID:
fetch_url <- qualtRics:::create_fetch_url(Sys.getenv("QUALTRICS_BASE_URL"), "SV_5XXXX")
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] "b44957a8-48bf-4198-ac02-db6f1b93c268"
#>
#> $httpStatus
#> [1] "200 - OK"
Created on 2021-04-06 by the reprex package (v2.0.0)
Thank you, I appreciate your help. Below is the output following the code you suggested:
library (qualtRics)
all_surveys()
#> Warning in check_for_warnings(cnt): Request proxied. For faster response times,
#> use this host instead: sjc1.qualtrics.com
#> # A tibble: 41 x 6
#> id name ownerId lastModified creationDate isActive
#> <chr> <chr> <chr> <chr> <chr> <lgl>
#> 1 SV_1KNCj… Inequality Test UR_41Mu4Q… 2021-04-05T15… 2021-03-13T21… TRUE
#> 2 SV_24Ahu… COVID Political … UR_81vnEn… 2020-06-19T03… 2020-05-26T16… TRUE
#> 3 SV_2gaDv… Colombia COVID-1… UR_81vnEn… 2020-09-14T18… 2020-09-12T00… FALSE
#> 4 SV_2i46H… Colombia COVID-1… UR_81vnEn… 2020-11-02T23… 2020-10-23T16… TRUE
#> 5 SV_3y1eD… Inequality and P… UR_41Mu4Q… 2021-04-05T15… 2021-01-12T20… FALSE
#> 6 SV_43oiS… Inequality_Party… UR_41Mu4Q… 2021-01-12T20… 2021-01-10T20… FALSE
#> 7 SV_5jyTg… Template Inequal… UR_4HPHdf… 2021-01-12T20… 2021-01-11T15… FALSE
#> 8 SV_73Npm… Brazil COVID-19 … UR_81vnEn… 2021-01-12T18… 2020-09-12T00… TRUE
#> 9 SV_79bS3… Chile COVID-19 R… UR_81vnEn… 2020-07-07T21… 2020-06-30T19… TRUE
#> 10 SV_861v5… Research Survey UR_6Dx3r3… 2021-01-05T21… 2020-12-13T20… TRUE
#> # … with 31 more rows
fetch_url <- qualtRics:::create_fetch_url(Sys.getenv("QUALTRICS_BASE_URL"), "SV_eS6m5fA6AJFrs9L")
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)
#> Error in qualtrics_response_codes(res): Qualtrics API raised a bad request (400) error - Please report this on
#> https://github.com/ropensci/qualtRics/issues
res$meta
#> Error in eval(expr, envir, enclos): object 'res' not found
And for the record, the QUALTRICS_BASE_URL
you are using and that host they are saying you should use instead are exactly the same, right?
That is correct!
Can you try pinging the whoami
end point (maybe outside of R) and see what it tells you? I would do this on the command line, like this (but with your URL):
curl --request GET \
--url https://conjoint.co1.qualtrics.com/API/v3/whoami \
--header 'x-api-token: YOURLONGAPITOKENHERE'
You should get some json back that looks like this:
{"result":{"brandId":"conjoint","userId":"UR_XXX","userName":"julia.silge@gmail.com","accountType":"UT_XXX","firstName":"Julia","lastName":"Silge","email":"julia.silge@gmail.com","datacenter":"co1"},"meta":{"requestId":"9ded5a28-2a5a-443a-a5d2-9c17f0356baf","httpStatus":"200 - OK"}}
I did get something that appears to make sense (I'll censor a few things below with XXX):
{"result":{"brandId":"wuXXX","userId":"UR_bXXXXXXX","userName":"1352432#wuXXX","accountType":"UT_9od1enVtTulsEwA","firstName":"GXXX","lastName":"Rosas","email":"grosas@XXX.edu","datacenter":"az1"},"meta":{"requestId":"6375f8f8-3fff-4dPSPSPSCIPPSCI0PPSPPPSCI005APSCI00PPPPPSPPPPPSPSCI00PSCI0PPSCIPSPPPP
etc.. (I'm not sure where the string ends). Are we looking for something in particular in this string?
Thanks!
I'm looking in particular for whether you got "httpStatus":"200 - OK"
in your result. Do you see that? Anything about the proxying?
Yes, that's exactly what I get:
"meta":{"requestId":"94afd7c8-5ee0-460a-8a3b-4dacec9acb85","httpStatus":"200 - OK","notice":"Request proxied. For faster response times, use this host instead: sjc1.qualtrics.com"}
Ah OK, I think you need to pursue this with Qualtrics, because it is not something happening with the R package but rather the API itself. I would create an example showing this curl result (the "Request proxied" bit) and post it on Qualtrics' API discussion section and also reach out to support. The strange thing here is that the two URLs look the same.
Thanks for your help, Julia, I will do just that.
Good luck! 💪
I have seen previous posts listing this "bad request" error, and consequently I've checked that the Qualtrics base URL is appropriately set. I believe I have followed all previous advice, and yet continue to receive this error code. The output of a reprex call appears below. Thanks for any advice you might have.
`library (qualtRics) Sys.getenv("QUALTRICS_BASE_URL")
> [1] "scj1.qualtrics.com"
surveys <- all_surveys()
> Warning in check_for_warnings(cnt): Request proxied. For faster response times,
> use this host instead: sjc1.qualtrics.com
mysurvey <- fetch_survey(surveyID = surveys$id[18] , verbose = TRUE)
> Error in qualtrics_response_codes(res): Qualtrics API raised a bad request (400) error - Please report this on
> https://github.com/ropensci/qualtRics/issues`