Alright. First off, I'm not going to be able to give a reprex, but I'd like to describe the situation, and if someone can point me in a direction -something to read, a clue, anything- I'd be grateful.
Thus far, I've read the vignettes for the httr and curl packages several times.
My problem: A financial institution offers an API to query economic/ market data via subscription and in real time via streaming data but I'm having trouble getting any data.
Here is a sketch of the tedium involved:
- get some account info using
httr::POST(some_url, with payload of secret login creds) %>% ...parse xml response...
- using the returned info from step 1), get 24 hour token using
httr::GET(some_new_url_with) %>% ...parse xml response...
SO FAR SO GOOD- ^^THIS WORKS
- now, using info from steps 1) and 2), I try to get the API to return a raw octet stream as promised by the API documentation, which can apparently be done via GET or POST.
To generate a kosher URL, the query string must be encoded, so using URLencode() I create something that looks like this:
my_url <- "http://my.domain.com/?AU%3D**_myLogin_**%26W%3D**_myToken_**%**_etc_**"
Now, if I simply try to httr::GET(my_url), this fails with the following error
Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, :
_ invalid 'trim' argument_
Then again, my reading of the httr vignette suggests that maybe it doesn't contemplate streaming info anyway and that I need to be starting with the curl package.
I therefore try the following:
req <- curl::curl_fetch_memory(command_total)
cat(rawToChar(req$headers))
HTTP/1.0 200 OK
Date: Mon 02 Mar 1998 10:20:00 GMT
Server: StreamerServer
Content-type: application/octet-stream
Pragma: no-cache
Cache-Control: no-cache
Accept-Ranges: none
Set-Cookie: NSC_QSPE-BTUNESN02-WJQ2-80-c01=ffffffff098yyyy04zz25dxxx58455e4422;expires=Sat, 02-Dec-2017 17:27:06 GMT;path=/;httponly
Whoa! It looks like I got something- including a 200 status code.
but, there's no content...ie req$content is raw(0)
So, I'm quite stuck as to how to tackle this next.