You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
library(httr)
#fabricated response from USDA NASS QuickStats API
r <- list(
url = "https://quickstats.nass.usda.gov/api/api_GET?key=<key removed>§or_desc=ECONOMICS&commodity_desc=RENT&prodn_practice_desc=IRRIGATED&class_desc=CROPLAND&agg_level_desc=COUNTY&year__GE=1997&format=JSON",
date = as.POSIXct("2017-12-20 22:43:47 GMT"),
headers = list('content-type' = ""),
content = charToRaw('{\"error\":[\"bad request - invalid query\"]}'))
class(r) <- "response"
class(r$headers) <- "insensitive"
#Call to httr::content without specifying type
content(r, as="text")
> Error in if (length(m) == 1 && m == -1) { :
missing value where TRUE/FALSE needed
#Works if specify type
content(r, as="text", type="text/json")
> '{\"error\":[\"bad request - invalid query\"]}'
This seems to be in the parse_media() function in media-parse.r, which works fine if type is NULL but not if type is "". type gets set to "" in the content() function if it is "" in the header.
The text was updated successfully, but these errors were encountered:
Reproducible example:
This seems to be in the parse_media() function in media-parse.r, which works fine if
type
isNULL
but not iftype
is""
.type
gets set to "" in thecontent()
function if it is""
in the header.The text was updated successfully, but these errors were encountered: