Closed dallinwebb closed 4 years ago
That sounds like an issue with curl, which did have some differences arise with R 4.0. See here and here. I thought that these issues were now resolved and you should be good to go after updating? You can see that I am fine on MacOS with R 4.0 and curl 4.3:
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-02-11T04:… 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-06-02 by the reprex package (v0.3.0)
Can you double check your curl version and if you still have problems, use reprex and perhaps call curl functions directly to isolate the problem?
I'm experiencing the same behavior with the current version of the curl package. Should I make a new issue on curl's github?
> R.version.string
[1] "R version 4.0.0 (2020-04-24)"
> packageVersion("qualtRics")
[1] ‘3.1.3’
> packageVersion("curl")
[1] ‘4.3’
> qualtRics::all_surveys()
Error in curl::curl_fetch_memory(url, handle = handle) :
Could not resolve host: https
Also, how did you create that Session info toggle in markdown?
Try using reprex(si = TRUE)
when you create reproducible examples; it is super helpful when tracking down version info! If you haven't used reprex before, check out this article.
Can you try calling some of the curl functions directly and make sure that is the problem? You'll need that to post an issue for curl anyway.
I've never used curl directly, but I ran this from one of their articles and it worked.
req <- curl_fetch_memory("https://eu.httpbin.org/get?foo=123")
str(req)
List of 7
$ url : chr "https://eu.httpbin.org/get?foo=123"
$ status_code: int 200
$ type : chr "application/json"
$ headers : raw [1:230] 48 54 54 50 ...
$ modified : POSIXct[1:1], format: NA
$ times : Named num [1:6] 0 0.083 0.162 0.306 0.377 ...
..- attr(*, "names")= chr [1:6] "redirect" "namelookup" "connect" "pretransfer" ...
$ content : raw [1:390] 7b 0a 20 20 ...
Yes, but the known problem was for URLs with no scheme.
Can you run the following using reprex()
with si = TRUE
so I can compare?
library(curl)
url <- "eu.httpbin.org/get?foo=123"
curl_fetch_memory(url)
#> $url
#> [1] "http://eu.httpbin.org/get?foo=123"
#>
#> $status_code
#> [1] 200
#>
#> $type
#> [1] "application/json"
#>
#> $headers
#> [1] 48 54 54 50 2f 31 2e 31 20 32 30 30 20 4f 4b 0d 0a 44 61 74 65 3a 20 54 75
#> [26] 65 2c 20 30 32 20 4a 75 6e 20 32 30 32 30 20 32 33 3a 30 36 3a 31 38 20 47
#> [51] 4d 54 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70 70 6c 69 63 61
#> [76] 74 69 6f 6e 2f 6a 73 6f 6e 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67 74 68
#> [101] 3a 20 33 37 30 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d 61
#> [126] 6c 69 76 65 0d 0a 53 65 72 76 65 72 3a 20 67 75 6e 69 63 6f 72 6e 2f 31 39
#> [151] 2e 39 2e 30 0d 0a 41 63 63 65 73 73 2d 43 6f 6e 74 72 6f 6c 2d 41 6c 6c 6f
#> [176] 77 2d 4f 72 69 67 69 6e 3a 20 2a 0d 0a 41 63 63 65 73 73 2d 43 6f 6e 74 72
#> [201] 6f 6c 2d 41 6c 6c 6f 77 2d 43 72 65 64 65 6e 74 69 61 6c 73 3a 20 74 72 75
#> [226] 65 0d 0a 0d 0a
#>
#> $modified
#> [1] NA
#>
#> $times
#> redirect namelookup connect pretransfer starttransfer
#> 0.000000 0.000989 0.065819 0.065861 0.138621
#> total
#> 0.138635
#>
#> $content
#> [1] 7b 0a 20 20 22 61 72 67 73 22 3a 20 7b 0a 20 20 20 20 22 66 6f 6f 22 3a 20
#> [26] 22 31 32 33 22 0a 20 20 7d 2c 20 0a 20 20 22 68 65 61 64 65 72 73 22 3a 20
#> [51] 7b 0a 20 20 20 20 22 41 63 63 65 70 74 22 3a 20 22 2a 2f 2a 22 2c 20 0a 20
#> [76] 20 20 20 22 41 63 63 65 70 74 2d 45 6e 63 6f 64 69 6e 67 22 3a 20 22 64 65
#> [101] 66 6c 61 74 65 2c 20 67 7a 69 70 22 2c 20 0a 20 20 20 20 22 48 6f 73 74 22
#> [126] 3a 20 22 65 75 2e 68 74 74 70 62 69 6e 2e 6f 72 67 22 2c 20 0a 20 20 20 20
#> [151] 22 55 73 65 72 2d 41 67 65 6e 74 22 3a 20 22 52 20 28 34 2e 30 2e 30 20 78
#> [176] 38 36 5f 36 34 2d 61 70 70 6c 65 2d 64 61 72 77 69 6e 31 37 2e 30 20 78 38
#> [201] 36 5f 36 34 20 64 61 72 77 69 6e 31 37 2e 30 29 22 2c 20 0a 20 20 20 20 22
#> [226] 58 2d 41 6d 7a 6e 2d 54 72 61 63 65 2d 49 64 22 3a 20 22 52 6f 6f 74 3d 31
#> [251] 2d 35 65 64 36 64 62 36 61 2d 63 38 31 37 33 35 34 64 35 33 35 39 30 31 32
#> [276] 62 37 63 35 33 39 62 37 61 22 0a 20 20 7d 2c 20 0a 20 20 22 6f 72 69 67 69
#> [301] 6e 22 3a 20 22 31 37 33 2e 32 33 31 2e 36 33 2e 31 30 34 22 2c 20 0a 20 20
#> [326] 22 75 72 6c 22 3a 20 22 68 74 74 70 3a 2f 2f 65 75 2e 68 74 74 70 62 69 6e
#> [351] 2e 6f 72 67 2f 67 65 74 3f 66 6f 6f 3d 31 32 33 22 0a 7d 0a
Created on 2020-06-02 by the reprex package (v0.3.0)
Finally got my first reprex to work.
curl::curl_fetch_memory("eu.httpbin.org/get?foo=123")
#> $url
#> [1] "eu.httpbin.org/get?foo=123"
#>
#> $status_code
#> [1] 200
#>
#> $type
#> [1] "application/json"
#>
#> $headers
#> [1] 48 54 54 50 2f 31 2e 31 20 32 30 30 20 4f 4b 0d 0a 44 61 74 65 3a 20 54 75
#> [26] 65 2c 20 30 32 20 4a 75 6e 20 32 30 32 30 20 32 33 3a 32 38 3a 35 30 20 47
#> [51] 4d 54 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70 70 6c 69 63 61
#> [76] 74 69 6f 6e 2f 6a 73 6f 6e 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67 74 68
#> [101] 3a 20 33 36 32 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d 61
#> [126] 6c 69 76 65 0d 0a 53 65 72 76 65 72 3a 20 67 75 6e 69 63 6f 72 6e 2f 31 39
#> [151] 2e 39 2e 30 0d 0a 41 63 63 65 73 73 2d 43 6f 6e 74 72 6f 6c 2d 41 6c 6c 6f
#> [176] 77 2d 4f 72 69 67 69 6e 3a 20 2a 0d 0a 41 63 63 65 73 73 2d 43 6f 6e 74 72
#> [201] 6f 6c 2d 41 6c 6c 6f 77 2d 43 72 65 64 65 6e 74 69 61 6c 73 3a 20 74 72 75
#> [226] 65 0d 0a 0d 0a
#>
#> $modified
#> [1] NA
#>
#> $times
#> redirect namelookup connect pretransfer starttransfer
#> 0.000000 0.057053 0.136352 0.136466 0.207489
#> total
#> 0.207518
#>
#> $content
#> [1] 7b 0a 20 20 22 61 72 67 73 22 3a 20 7b 0a 20 20 20 20 22 66 6f 6f 22 3a 20
#> [26] 22 31 32 33 22 0a 20 20 7d 2c 20 0a 20 20 22 68 65 61 64 65 72 73 22 3a 20
#> [51] 7b 0a 20 20 20 20 22 41 63 63 65 70 74 22 3a 20 22 2a 2f 2a 22 2c 20 0a 20
#> [76] 20 20 20 22 41 63 63 65 70 74 2d 45 6e 63 6f 64 69 6e 67 22 3a 20 22 64 65
#> [101] 66 6c 61 74 65 2c 20 67 7a 69 70 22 2c 20 0a 20 20 20 20 22 48 6f 73 74 22
#> [126] 3a 20 22 65 75 2e 68 74 74 70 62 69 6e 2e 6f 72 67 22 2c 20 0a 20 20 20 20
#> [151] 22 55 73 65 72 2d 41 67 65 6e 74 22 3a 20 22 52 20 28 34 2e 30 2e 30 20 78
#> [176] 38 36 5f 36 34 2d 77 36 34 2d 6d 69 6e 67 77 33 32 20 78 38 36 5f 36 34 20
#> [201] 6d 69 6e 67 77 33 32 29 22 2c 20 0a 20 20 20 20 22 58 2d 41 6d 7a 6e 2d 54
#> [226] 72 61 63 65 2d 49 64 22 3a 20 22 52 6f 6f 74 3d 31 2d 35 65 64 36 65 30 62
#> [251] 32 2d 63 34 30 63 63 38 64 34 63 31 34 39 34 31 31 61 36 64 38 61 63 62 62
#> [276] 65 22 0a 20 20 7d 2c 20 0a 20 20 22 6f 72 69 67 69 6e 22 3a 20 22 32 31 36
#> [301] 2e 34 39 2e 31 38 31 2e 32 35 33 22 2c 20 0a 20 20 22 75 72 6c 22 3a 20 22
#> [326] 68 74 74 70 3a 2f 2f 65 75 2e 68 74 74 70 62 69 6e 2e 6f 72 67 2f 67 65 74
#> [351] 3f 66 6f 6f 3d 31 32 33 22 0a 7d 0a
Created on 2020-06-02 by the reprex package (v0.3.0)
OK, so it looks like curl is fine.
Try running this, and check out your URL and headers (don't paste your headers here because they involve your API key):
library(qualtRics)
url <- qualtRics:::create_surveys_url(Sys.getenv("QUALTRICS_BASE_URL"))
url
#> [1] "https://conjoint.co1.qualtrics.com/API/v3/surveys/"
headers <- qualtRics:::construct_header(Sys.getenv("QUALTRICS_API_KEY"))
httr::GET(url = url, httr::add_headers(headers))
#> Response [https://conjoint.co1.qualtrics.com/API/v3/surveys/]
#> Date: 2020-06-03 14:38
#> Status: 200
#> Content-Type: application/json
#> Size: 850 B
Created on 2020-06-03 by the reprex package (v0.3.0)
url <- qualtRics:::create_surveys_url(Sys.getenv("QUALTRICS_BASE_URL"))
url
#> [1] "https://https://byui.az1.qualtrics.com/API/v3/surveys/"
headers <- qualtRics:::construct_header(Sys.getenv("QUALTRICS_API_KEY"))
httr::GET(url = url, httr::add_headers(headers))
#> Error in curl::curl_fetch_memory(url, handle = handle): Could not resolve host: https
Created on 2020-06-03 by the reprex package (v0.3.0)
Ah, look at the URL! Something is very messed up there. What is in your BASE_URL
? It should be something like this:
Sys.getenv("QUALTRICS_BASE_URL")
#> [1] "conjoint.co1.qualtrics.com"
Created on 2020-06-03 by the reprex package (v0.3.0)
Notice that when you register your credentials:
The base URL you pass to the qualtRics package should either look like
yourdatacenterid.qualtrics.com
or likeyourorganizationid.yourdatacenterid.qualtrics.com
That was it! User error. Sorry for the distraction but thanks for all the help!
Sounds good!
I get this error when using this and the
fetch_survey()
function in the latest version of R.I've get the same error with the development version of the package. After rolling back to R version 3.6.3, the functions work fine.