wiscostret / fplscrapR

This package enables those interested in Fantasy Premier League to perform detailed data analysis of the game, using the FPL's JSON API. The fplscrapR functions help R users collect and parse data from the Official Fantasy Premier League website.
Creative Commons Zero v1.0 Universal
77 stars 16 forks source link

JSON parsing error with `get_player_details()` #12

Closed gtm19 closed 4 years ago

gtm19 commented 4 years ago

Getting the following error when trying to render an .Rmd code block containing fplscrapR::get_player_details() with no arguments (so as to return this seasons' stats)

Rendering 2020-01-25-fantasy-premier-league-1.Rmd
Quitting from lines 67-72 (2020-01-25-fantasy-premier-league-1.Rmd) 
Error in parse_con(txt, bigint_as_char) : parse error: premature EOF

                     (right here) ------^
Calls: local ... <Anonymous> -> parse_and_simplify -> parseJSON -> parse_con
Execution halted
wiscostret commented 4 years ago

Have you updated/installed the package recently? We pushed an update to the package on 10 Jan which solved an issue with get_player_details()

gtm19 commented 4 years ago

@wiscostret I installed it for the first time yesterday.

From a bit of Googling, premature EOF looks like a common error when querying APIs for JSON, where the connection is interrupted or refused. Since this command works when I run it interactively in R, but errors when I try to knit the RMarkdown file, my guess is that FPL's API endpoint is refusing the connection.

wiscostret commented 4 years ago

Thanks. Occasionally the API will refuse a connection but if the issue is consistent, I think it's likely to do with the parsing rather than your choice of console. Other users have recently reported issues with parsing from the API using the fplscrapR package, though I have not yet been able to reproduce the issues. Will take an extra look as soon as possible.

wiscostret commented 4 years ago

Hi, sorry for getting back to this late, was just reviewing issues again. Is this still a problem? I wasn´t able to find an reproducible issue on the parsing.

gtm19 commented 4 years ago

I'd say you can probably close it.

I can still replicate the issue, but only by clicking Knit at the top of RStudio. The error does not occur when running rmarkdown::render() in the R console.

This is odd, because it appears that clicking Knit should call the render() function, but :man_shrugging:.

Either way I think it's an RStudio issue. Perhaps even this one in particular.

wiscostret commented 4 years ago

Huh, strange one. Thanks for the info - I will close this issue but look into it further, see if there´s anything I can do for the next package update.