Closed Eshijalote closed 4 years ago
Well, that does mean your credentials are being set correctly. 👍
Can you: a) reinstall from CRAN
install.packages("qualtRics")
b) run the following code using reprex, to make sure that nothing weird is happening environment-wise? Paste what you get here for us if you still get an error.
library(qualtRics)
my_survey <- "PUTYOURIDHERE"
fetch_survey(my_survey)
If you credentials are in .Renviron
, I believe that reprex will find them just fine (at least it just did for me when I tried it out). You can paste "XXXXX" over anything that gets printed out that is PII such as your survey ID.
Hi,
Yes I have tried all these things. I saw these notes in an open issue and have already tried it. I still get the same bad request.
Thanks, Eshi
On Apr 9, 2020, at 5:43 PM, Julia Silge notifications@github.com wrote:
Well, that does mean your credentials are being set correctly. 👍
Can you: a) reinstall from CRAN
install.packages("qualtRics") b) run the following code using reprex, to make sure that nothing weird is happening environment-wise? Paste what you get here for us if you still get an error.
library(qualtRics) my_survey <- "PUTYOURIDHERE" fetch_survey(my_survey) If you credentials are in .Renviron, I believe that reprex will find them just fine (at least it just did for me when I tried it out). You can paste "XXXXX" over anything that gets printed out that is PII such as your survey ID.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
OK, great! Can you paste using reprex and then we can move on to dig into what the problem is?
library(qualtRics) library(reprex)
qualtrics_api_credentials(api_key=Sys.getenv("qualtrics_api_key"), base_url=Sys.getenv("qualtrics_base_url"), install = TRUE, overwrite = TRUE )
readRenviron("~/.Renviron")
surveys <- all_surveys()
mysurvey <- qualtRics::fetch_survey(surveyID = 'SV_3sZ5X9ya8loC7VX')
Hi this is the reprex
Can you try one more time and just paste what is on your clipboard after you run the reprex? It should look almost exactly like this, except showing the failure:
library(qualtRics)
my_survey <- "SV_5BJRo2RGHajIlOB"
fetch_survey(my_survey)
#> | | | 0% | |========================================================== | 83% | |======================================================================| 100%
#> Parsed with column specification:
#> cols(
#> .default = col_character(),
#> StartDate = col_datetime(format = ""),
#> EndDate = col_datetime(format = ""),
#> IPAddress = col_logical(),
#> Progress = col_double(),
#> `Duration (in seconds)` = col_double(),
#> Finished = col_logical(),
#> RecordedDate = col_datetime(format = ""),
#> RecipientLastName = col_logical(),
#> RecipientFirstName = col_logical(),
#> RecipientEmail = col_logical(),
#> ExternalReference = col_logical(),
#> LocationLatitude = col_double(),
#> LocationLongitude = col_double(),
#> Q1007 = col_double(),
#> Q1_DO_1 = col_double(),
#> Q1_DO_2 = col_double(),
#> Q1_DO_3 = col_double(),
#> Q1_DO_4 = col_double(),
#> Q1_DO_5 = col_double(),
#> SolutionRevision = col_double()
#> # ... with 5 more columns
#> )
#> See spec(...) for full column specifications.
#> Warning in infer_data_types(data, surveyID): The 'StartDate', 'EndDate' and 'RecordedDate' variables were converted without passing
#> a specific timezone. If you like to set these timestamps to your own timezone, please
#> visit https://www.qualtrics.com/support/survey-platform/getting-started/managing-your-account/
#> (under 'User Settings'). See https://api.qualtrics.com/docs/dates-and-times for more
#> information about how the Qualtrics API handles dates and times.
#> # A tibble: 121 x 46
#> StartDate EndDate Status IPAddress Progress
#> <dttm> <dttm> <chr> <lgl> <dbl>
#> 1 2020-03-29 20:47:24 2020-03-29 20:48:23 Surve… NA 100
#> 2 2020-03-29 20:50:02 2020-03-29 20:50:02 Surve… NA 100
#> 3 2020-03-29 20:50:02 2020-03-29 20:50:02 Surve… NA 100
#> 4 2020-03-29 20:50:02 2020-03-29 20:50:02 Surve… NA 100
#> 5 2020-03-29 20:50:03 2020-03-29 20:50:03 Surve… NA 100
#> 6 2020-03-29 20:50:03 2020-03-29 20:50:03 Surve… NA 100
#> 7 2020-03-29 20:50:03 2020-03-29 20:50:03 Surve… NA 100
#> 8 2020-03-29 20:50:03 2020-03-29 20:50:03 Surve… NA 100
#> 9 2020-03-29 20:50:03 2020-03-29 20:50:03 Surve… NA 100
#> 10 2020-03-29 20:50:03 2020-03-29 20:50:03 Surve… NA 100
#> # … with 111 more rows, and 41 more variables: `Duration (in seconds)` <dbl>,
#> # Finished <lgl>, RecordedDate <dttm>, ResponseId <chr>,
#> # RecipientLastName <lgl>, RecipientFirstName <lgl>, RecipientEmail <lgl>,
#> # ExternalReference <lgl>, LocationLatitude <dbl>, LocationLongitude <dbl>,
#> # DistributionChannel <chr>, UserLanguage <chr>, Q1002 <ord>, Q1006 <ord>,
#> # Q1007 <dbl>, Q1_1 <chr>, Q1_2 <chr>, Q1_3 <chr>, Q1_4 <chr>, Q1_5 <chr>,
#> # Q1_DO_1 <dbl>, Q1_DO_2 <dbl>, Q1_DO_3 <dbl>, Q1_DO_4 <dbl>, Q1_DO_5 <dbl>,
#> # Q200 <ord>, Q300 <ord>, Q201 <ord>, Q301 <ord>, Q202 <ord>, Q302 <ord>,
#> # Q203 <ord>, Q303 <ord>, Q204 <ord>, Q304 <ord>, SolutionRevision <dbl>,
#> # FL_6_DO_FL_7 <dbl>, FL_6_DO_FL_8 <dbl>, FL_6_DO_FL_9 <dbl>,
#> # FL_6_DO_FL_10 <dbl>, FL_6_DO_FL_11 <dbl>
Created on 2020-04-09 by the reprex package (v0.3.0)
I need you to read this page and follow those steps to paste the actual output from the reprex()
function, to make sure nothing weird is going on with your environment. What you have pasted here doesn't look like the output from an updated version of the reprex package. I know this can be a pain, but it will really help moving forward if we are going to dig into the JSON payload you are sending. We can't really move forward until we've got you successfully using reprex. This is a very helpful article if you haven't used reprex before.
library(qualtRics)
qualtrics_api_credentials(api_key=Sys.getenv("qualtrics_api_key"),
base_url=Sys.getenv("qualtrics_base_url"),
install = TRUE,
overwrite = TRUE
)
#> Your original .Renviron will be backed up and stored in your R HOME directory if needed.
#> Your Qualtrics key and base URL have been stored in your .Renviron.
#> To use now, restart R or run `readRenviron("~/.Renviron")`
surveys <- all_surveys()
mysurvey <- qualtRics::fetch_survey(surveyID = 'SV_3sZ5X9ya8loC7VX')
#>
|
| | 0%
|
|=================================================================| 100%
#> Parsed with column specification:
#> cols(
#> .default = col_double(),
#> StartDate = col_datetime(format = ""),
#> EndDate = col_datetime(format = ""),
#> Status = col_character(),
#> IPAddress = col_character(),
#> Finished = col_logical(),
#> RecordedDate = col_datetime(format = ""),
#> ResponseId = col_character(),
#> RecipientLastName = col_logical(),
#> RecipientFirstName = col_logical(),
#> RecipientEmail = col_logical(),
#> ExternalReference = col_logical(),
#> DistributionChannel = col_character(),
#> UserLanguage = col_character(),
#> `wstimer_First Click` = col_logical(),
#> `wstimer_Last Click` = col_logical(),
#> `wstimer_Page Submit` = col_logical(),
#> `wstimer_Click Count` = col_logical()
#> )
#> See spec(...) for full column specifications.
#> Warning in infer_data_types(data, surveyID): The 'StartDate', 'EndDate' and 'RecordedDate' variables were converted without passing
#> a specific timezone. If you like to set these timestamps to your own timezone, please
#> visit https://www.qualtrics.com/support/survey-platform/getting-started/managing-your-account/
#> (under 'User Settings'). See https://api.qualtrics.com/docs/dates-and-times for more
#> information about how the Qualtrics API handles dates and times.
Created on 2020-04-09 by the reprex package (v0.3.0)
Does this look like the reprex.
Yes! But it works. You successfully downloaded the survey. 👍 Looks like everything is working correctly here.
To clarify a little bit about the credentials, you don't have to write them to your .Renviron
every time. Once you write them there one time, they are stored there until you delete them or overwrite them. Try restarting R, and running just this code in a fresh session:
library(qualtRics)
fetch_survey(surveyID = 'SV_3sZ5X9ya8loC7VX')
But it does not work. I still get that 404 error.
Thanks, Eshi
On Apr 9, 2020, at 8:58 PM, Julia Silge notifications@github.com wrote:
To clarify a little bit about the credentials, you don't have to write them to your .Renviron every time. Once you write them there one time, they are stored there until you delete them or overwrite them. Try restarting R, and running just this code in a fresh session:
library(qualtRics) fetch_survey(surveyID = 'SV_3sZ5X9ya8loC7VX') — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Can you explain what does not work? If you look in the reprex you created, it does work. You successfully downloaded the survey. Can you run the following code in a reprex and paste the results here?
library(qualtRics)
fetch_survey(surveyID = 'SV_3sZ5X9ya8loC7VX')
mysurvey <- qualtRics::fetch_survey(surveyID = 'SV_3sZ5X9ya8loC7VX') Error in qualtrics_response_codes(res) : Qualtrics API raised a bad request (400) error - Please report this on https://github.com/ropensci/qualtRics/issues
I don't have the variable my survey in the environment. In reprex it shows this but when I am running the code there is nothing and while running using reprex also still I don't see mySurvey with the data
Yes, you don't need mySurvey
. Just run this in the reprex and see what happens:
library(qualtRics)
fetch_survey(surveyID = 'SV_3sZ5X9ya8loC7VX')
Please paste the output of the reprex()
function here.
qualtRics::fetch_survey(surveyID = 'SV_3sZ5X9ya8loC7VX') Error in qualtrics_response_codes(res) : Qualtrics API raised a bad request (400) error - Please report this on https://github.com/ropensci/qualtRics/issues Rendering reprex... Rendered reprex is on the clipboard.
The reprex is not showing the error but I need a variable mySurvey or another variable to look at the survey data. And the code is not running. Reprex is not depicting what happens when I actually run the code
Yes, that is the key! We have to get the reprex to show the error for us to be able to help you.
The difference between the reprex and your "normal" workflow is the environment you are working in. I suspect that something has gone weird in your environment; you should try things like restarting R very often, never saving .RData
, and other good practices.
Thank you restarting the session made it work.
I am using this command mysurvey <- fetch_survey(surveyID = surveys$id[12]) and I get a 400 error. My credentials are fine as I just used all_surveys() and it gets all the surveys.