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

Error in qualtrics_response_codes() for fetch_distributions() & 0 observations for all_mailinglists() #271

Open
zoe-zhang99 opened this issue Jul 11, 2022 · 11 comments · May be fixed by #275

Comments

@zoe-zhang99
Copy link

Dear developers,

I ran into these two issues while running the package, and my API worked well to fetch the survey.

I got 0 observations for all_mailinglists(). No error message.

For fetch-distributions():

> distributions <- fetch_distributions(surveys$id[1])
Error in `qualtrics_response_codes()`:
! Qualtrics API raised a bad request (400) error - Please report this on
https://github.com/ropensci/qualtRics/issues
Run `rlang::last_error()` to see where the error occurred.
> rlang::last_error()
<error/rlang_error>
Error in `qualtrics_response_codes()`:
! Qualtrics API raised a bad request (400) error - Please report this on
https://github.com/ropensci/qualtRics/issues
---
Backtrace:
 1. qualtRics::fetch_distributions(surveys$id[1])
 2. qualtRics:::qualtrics_api_request("GET", url = fetch_url)
 3. qualtRics:::qualtrics_response_codes(res)
Run `rlang::last_trace()` to see the full context.
> rlang::last_trace()
<error/rlang_error>
Error in `qualtrics_response_codes()`:
! Qualtrics API raised a bad request (400) error - Please report this on
https://github.com/ropensci/qualtRics/issues
---
Backtrace:
    ▆
 1. └─qualtRics::fetch_distributions(surveys$id[1])
 2.   └─qualtRics:::qualtrics_api_request("GET", url = fetch_url)
 3.     └─qualtRics:::qualtrics_response_codes(res)
 4.       └─rlang::abort("Qualtrics API raised a bad request (400) error - Please report this on\nhttps://github.com/ropensci/qualtRics/issues")

Thanks for your help & look forward to getting your reply.

@juliasilge
Copy link
Collaborator

@zoe-zhang99 Have you updated your version of the qualtRics R package lately? This looks like an older version of the error message to me. You can try the development version via:

## install.packages("remotes")
remotes::install_github("ropensci/qualtRics")

@zoe-zhang99
Copy link
Author

zoe-zhang99 commented Jul 15, 2022

Hi Julia @juliasilge ,

For distribution, I am still receiving the same error message after updating the package.

In the meantime, I wonder what the mailinglist returns as I am getting 0 now. Should I use the default email question in Qualtrics to get a return of email list or I can get it from my own email question? As for now, I do have 4 columns empty for the survey results ("RecipientLastName", "RecipientFirstName", "RecipientEmail", "ExternalReference"), does the mailinglist come from the column I list here?

Thanks!

@juliasilge
Copy link
Collaborator

@zoe-zhang99 Can you use reprex to run the following code, replacing my surveyID with yours?

## use _your_ surveyID here:
fetch_url <- qualtRics::generate_url(query = "fetchdistributions",
                                     surveyID = "SV_3gbwq8aJgqPwQDP")
res <- qualtRics:::qualtrics_api_request("GET", url = fetch_url)
res$meta
#> $httpStatus
#> [1] "200 - OK"
#> 
#> $requestId
#> [1] "dc48c980-b7c3-4ea1-aae5-b1e2c563fc79"

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

@zoe-zhang99
Copy link
Author

@juliasilge Thanks! I didn't have access to distribution before, the problem is solved. Thank you!
I still have questions for mailinglist though. My understanding is that it will give back the participants' email right? Or it is other emails?

@juliasilge
Copy link
Collaborator

I wonder if something has changed in the API and we need to update the call for the mailinglist endpoint:
https://api.qualtrics.com/dd83f1535056c-list-mailing-lists

Notice that these docs include a directoryId but we don't include that right now:

qualtRics::generate_url(query = "allmailinglists")
#> https://conjoint.co1.qualtrics.com/API/v3/mailinglists/

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

@dsen6644 I know you worked on this and have used the all_mailinglists() function in your work. Are you aware of a change since we added this functionality?

@pschatz25
Copy link

Something definitely seems to have changed with mailinglists.

fetch_mailinglist(survey_file$id[1])

Now returns:

Error in qualtrics_response_codes(): ! Qualtrics API raised a bad request (400) error

Qualtrics very recently migrated my brand to the XM Directory, which seemed to coincide with fetch_mailinglist starting to throw that error. I've been using this function to pull embeddedData from the mailinglist.

@juliasilge
Copy link
Collaborator

I don't have any real data or experience with the mailing lists. I would so appreciate a PR from someone who uses this in their real world work! I can review and make sure it's all good to go if someone who has a real use case can set it up. 👍

@pschatz25
Copy link

I'm a Git newbie and I don't write the greatest code, but I'd like to try to be helpful here. A couple years ago I wrote a script to pull Qualtrics data and output a file to be imported into Tableau. Here's the section of code that pulls mailinglist data as part of a loop:

mailinglist <- fetch_mailinglist(mailinglistID = p)
mailinglist_meta <- mailinglist %>% select(1:7)
mailinglist_embeddedData <- mailinglist %>% select(-(1:7)) %>% rename_with( ~ paste0('Panel_', .x))
mailinglist_final <- bind_cols(mailinglist_meta, mailinglist_embeddedData)

Hopefully this helps describe a real use case. Pulling the embedded data is crucial to my process. Now before someone points this out, I could get the embedded data from fetch_survey. The fields after the last question are embedded data. The drawback of that approach is it requires all the fields to have been correctly embedded before the survey was launched. While that's generally true for my surveys for various reasons it's not always true. Using fetch_mailinglist worked perfectly for what I need.

@juliasilge
Copy link
Collaborator

@pschatz25 I am glad that fetch_mailinglist() worked for you, although such a bummer that it no longer works! If you are interested in trying a PR, I recommend this guide from previous tidyverse developer days for getting started. You can take a look at the existing functions to see how they typically work.

@dsen6644
Copy link
Contributor

dsen6644 commented Aug 9, 2022

Yes, Qualtrics has been positioning themselves to drop the concept of mailing lists and use more of a directory-centric approach to distributing survey emails. Although I never received any notifications from them that it actually went into effect.

I'll begin reviewing the new features and reach out to support to see if this affects all accounts. I'm surprised this didn't impact the fetch_distributions features given how intertwined they are.

@juliasilge
Copy link
Collaborator

Huge thanks to @dsen6644 for the PR addressing this problem! If you would be willing to try it out, you can install that branch with the fix via:

remotes::install_github("ropensci/qualtRics#275")

I don't have any real data or experience with the mailing lists so we would appreciate some folks trying it out!

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

Successfully merging a pull request may close this issue.

4 participants