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

API raised a bad request #255

Closed
LarryVincent opened this issue Apr 2, 2022 · 14 comments
Closed

API raised a bad request #255

LarryVincent opened this issue Apr 2, 2022 · 14 comments

Comments

@LarryVincent
Copy link

Have been using this package for a while with no issues. It works perfectly on my academic account and on an account for a client. But when I tried to fetch a survey with my consulting practice account I got an error message saying "Qualtrics API raised a bad request(400) error - Please report this message om ROpenSci."

I am able to use all_surveys() without issue, so it seems to be authenticating. I just can't fetch any surveys. Here's the command sent:

df <- fetch_survey(surveyID = SURVEY_ID,
force_request = TRUE)

Here's the 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_survey(surveyID = s$id[1], verbose = TRUE)
  2. qualtRics:::qualtrics_api_request("POST", url = fetch_url, body = raw_payload)
  3. qualtRics:::qualtrics_response_codes(res)
    Run rlang::last_trace() to see the full context.
@janitabotha
Copy link

I am having the same issue as described above!

@juliasilge
Copy link
Collaborator

Are these related to #246? Are these shared surveys from another organization?

@LarryVincent
Copy link
Author

No. This is my private account and the survey is not shared. I have since launched two other surveys with the same issue. Again, all_surveys() works fine. I just can't fetch. I've tried numerous configurations (e.g., force = TRUE, etc.). I get the same API error. Since I do not have this problem on my academic account, I'm wondering if it is a setting on Qualtrics. I could not find any options in my Admin panel.

@juliasilge
Copy link
Collaborator

@LarryVincent Just checking here -- you are sure you purchased API access on your private (non-academic) account? For example, in your account section, you see this API section:

Qualtrics_IDs___Qualtrics_Experience_Management

Just also checking, you are using the API key/token from your personal account, not accidentally using the one from your academic account?

@LarryVincent
Copy link
Author

Yes. I am able to generate a token and I am able to access my private account via API.

@juliasilge
Copy link
Collaborator

OK, next thing to check -- do you get messages about your request being proxied? Like in #229 and #211?

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)

@janitabotha
Copy link

janitabotha commented Apr 4, 2022 via email

@LarryVincent
Copy link
Author

LarryVincent commented Apr 5, 2022 via email

@juliasilge
Copy link
Collaborator

@LarryVincent You might want to try this as well to see if anything is weird in what you get back:

curl --request GET \
--url https://conjoint.co1.qualtrics.com/API/v3/whoami \
--header 'x-api-token: YOURLONGAPITOKENHERE'

This would be called from the command line (not from R) and you would need to use your URL and your API token.

@LarryVincent
Copy link
Author

It's very odd. I just spent an hour on the phone with Qualtrics to ensure there wasn't a permissions problem on the account. They say it's fully enabled and that the logs only show 200 requests, no 400 requests. I ran the code above and here are the (slightly redacted) results:

{"result":{"brandId":"conclusive","userId":"-REDACTED-","userName":"-REDACTED-","accountType":"UT_BRANDADMIN","firstName":"Larry","lastName":"Vincent","email":"-REDACTED-","datacenter":"az1"},"meta":{"requestId":"9860c302-d1ae-4a5a-b059-5b6a3274f7b6","httpStatus":"200 - OK","notice":"Request proxied. For faster response times, use this host instead: sjc1.qualtrics.com"}}(base)

@juliasilge
Copy link
Collaborator

Aaaaah OK @LarryVincent I think you have the "request proxied" problem that is the same as reported in #211 and #229!! Can you change your host to the host they recommend?

@LarryVincent
Copy link
Author

That solved the problem! Thank you @juliasilge . This package is my lifeline and you're always quick to help us troubleshoot. Appreciate you! I have also logged this with Qualtrics API support team. Hopefully, it will be in their database for future challenges with others.

@juliasilge
Copy link
Collaborator

I'm going to leave this issue and add a note in the vignette or something about this "request proxied" problem.

@daaronr
Copy link

daaronr commented Jul 25, 2022

Aaaaah OK @LarryVincent I think you have the "request proxied" problem that is the same as reported in #211 and #229!! Can you change your host to the host they recommend?

@juliasilge I don't see which 'host they recommend there' Can you advise please? Thanks.

Ah, you mean the one raised in the error message, got it! I.e., base_url = myorganization.sjc1.qualtrics.com

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

4 participants