Reputation: 23
I'm trying to update a project from March 2018. Previously, I had used
library("httr")
library("rjson")
api.url <- "http://api.tvmaze.com/lookup/shows?imdb=tt1325113"
response <- GET(api.url)
response.list <- fromJSON(content(response))
Previously, this returned a list containing the parsed json information that I used sapply to extract the relevant information from. Now, it's showing
Error in UseMethod("content", x) :
no applicable method for 'content' applied to an object of class "response"
There appears to be some kind of change in the httr package but I can't figure out what it is. Any ideas of what might be different and how to get around it?
Upvotes: 2
Views: 991
Reputation: 11
It is most likely a pkg conflict issue only, make sure you reference the pkg name:
httr::content(response)
That because some pkgs use same function name, like NLP::content()
.
Hope this will help in your case.
Upvotes: 0
Reputation: 281
You have to specify the as
argument of content, the code below should do the trick.
library("httr")
library("rjson")
api.url <- "http://api.tvmaze.com/lookup/shows?imdb=tt1325113"
response <- GET(api.url)
response.list <-
fromJSON(content(response, as = "text"))
Upvotes: 1