2

I am trying to load questions from the Stack Overflow API and I get an error about an embedded nul in the string.

document = getURL("https://api.stackexchange.com/2.2/questions?page=1&pagesize=15&order=desc&sort=creation&tagged=R&site=stackoverflow")
Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) : 
  embedded nul in string: '\037<U+008B>\b'

I've tried other methods of retrieving the page, but they result in a string of incomprehensible numbers and letters, such as using the function getURLContent()

1
  • What you get from getURL is a compressed JSON (through gzip). You have to decompress the object in order to read it.
    – nicola
    Dec 2, 2015 at 7:03

1 Answer 1

1

It's probably a https problem. Try httr:

content(GET("https://api.stackexchange.com/2.2/questions?page=1&pagesize=15&order=desc&sort=creation&tagged=R&site=stackoverflow"))

$items
$items[[1]]
$items[[1]]$tags
$items[[1]]$tags[[1]]
[1] "r"

$items[[1]]$tags[[2]]
[1] "osx"

$items[[1]]$tags[[3]]
[1] "ggplot2"

... cut off
1
  • This was it. Removed the s in https and now it works.
    – Jack Cole
    Dec 2, 2015 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.