ffverse / ffscrapr

R API Client for Fantasy Football League Platforms
https://ffscrapr.ffverse.com
Other
76 stars 21 forks source link

ESPN Transaction History #418

Closed thunderplayer17 closed 9 months ago

thunderplayer17 commented 9 months ago

Describe the bug Using the ff_transaction function and it says there is no transaction history for any of the years of the league. All of the other functions I have tried worked just not this one.

Reprex Please provide a short, reproducible example of the code you are trying to run. For more on reprexes, check out https://reprex.tidyverse.org ff_transactions(conn)

> Error in ff_transactions(conn): could not find function "ff_transactions"

 # Please include the code used for the connection object from `ff_connect()`
conn <- espn_connect(
  league_id = 286043,
  espn_s2 = Sys.getenv("TAN_ESPN_S2"),
  swid = Sys.getenv("TAN_SWID")
)

Expected behavior A clear and concise description of what you expected to happen. A dataframe of transaction history

Session information Please copy the output of ffscrapr::ffverse_sitrep() into the box below.

── System Info ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• R version 4.3.1 (2023-06-16 ucrt) • Running under: Windows 10 x64 (build 19045)
── Package Status ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   package installed  cran      dev behind
1 ffscrapr     1.4.8 1.4.8 1.4.8.13    dev
── Package Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• No options set for above packages
── Package Dependencies ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• askpass    (1.2.0)   • jsonlite   (1.8.7)   • stringr    (1.5.0)  
• assertthat (0.2.1)   • lifecycle  (1.0.3)   • sys        (3.4.2)  
• backports  (1.4.1)   • magrittr   (2.0.3)   • tibble     (3.2.1)  
• cachem     (1.0.8)   • memoise    (2.0.1)   • tidyr      (1.3.0)  
• checkmate  (2.2.0)   • mime       (0.12)    • tidyselect (1.2.0)  
• cli        (3.6.1)   • nflreadr   (1.4.0)   • utf8       (1.2.3)  
• cpp11      (0.4.6)   • openssl    (2.1.1)   • vctrs      (0.6.3)  
• curl       (5.0.2)   • pillar     (1.9.0)   • withr      (2.5.1)  
• data.table (1.14.8)  • pkgconfig  (2.0.3)   • graphics   (4.3.1)  
• dplyr      (1.1.3)   • purrr      (1.0.2)   • grDevices  (4.3.1)  
• fansi      (1.0.4)   • R6         (2.5.1)   • methods    (4.3.1)  
• fastmap    (1.1.1)   • rappdirs   (0.3.3)   • stats      (4.3.1)  
• generics   (0.1.3)   • ratelimitr (0.4.1)   • tools      (4.3.1)  
• glue       (1.6.2)   • rlang      (1.1.1)   • utils      (4.3.1)  
• httr       (1.4.7)   • stringi    (1.7.12)    
── Not Installed ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• ffsimulator  • ffpros  • ffopportunity  

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

tanho63 commented 9 months ago

I would guess that the espn_s2 and swid configs are not set up properly, have you read through this vignette? https://ffscrapr.ffverse.com/articles/espn_authentication.html

Also, please provide the sitrep.

thunderplayer17 commented 9 months ago

Yeah I read through the article and got the configs from the browser. The other functions I use with the same connection work. I will add the sitrep.

tanho63 commented 9 months ago

Does installing the latest development version of ffscrapr solve the problem? noticed the dev version is a good deal ahead of where cran is rn

thunderplayer17 commented 9 months ago

Installed the dev version and having the same issue. Was able to try ff_rosters() and it worked. Seems to be isolated to the ff_transaction function. Below is part of the terminal and an updated sitrep.

> ff_transactions(conn)
Request failed [401]. Retrying in 1 seconds...
Request failed [401]. Retrying in 1.8 seconds...
NULL
Warning messages:
1: ESPN API request failed with <Client error: (401) Unauthorized> 

while calling <https://fantasy.espn.com/apis/v3/games/ffl/seasons/2023/segments/0/leagues/286043/communication/?view=kona_league_communication> 
2: No transactions found for 2023 - 286043! 
> ffscrapr::ffverse_sitrep()
── System Info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• R version 4.3.1 (2023-06-16 ucrt) • Running under: Windows 10 x64 (build 19045)
── Package Status ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   package installed  cran      dev behind
1 ffscrapr  1.4.8.13 1.4.8 1.4.8.13       
── Package Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• No options set for above packages
── Package Dependencies ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• askpass    (1.2.0)   • jsonlite   (1.8.7)   • stringr    (1.5.0)  
• assertthat (0.2.1)   • lifecycle  (1.0.3)   • sys        (3.4.2)  
• backports  (1.4.1)   • magrittr   (2.0.3)   • tibble     (3.2.1)  
• cachem     (1.0.8)   • memoise    (2.0.1)   • tidyr      (1.3.0)  
• checkmate  (2.2.0)   • mime       (0.12)    • tidyselect (1.2.0)  
• cli        (3.6.1)   • nflreadr   (1.4.0)   • utf8       (1.2.3)  
• cpp11      (0.4.6)   • openssl    (2.1.1)   • vctrs      (0.6.3)  
• curl       (5.0.2)   • pillar     (1.9.0)   • withr      (2.5.1)  
• data.table (1.14.8)  • pkgconfig  (2.0.3)   • graphics   (4.3.1)  
• dplyr      (1.1.3)   • purrr      (1.0.2)   • grDevices  (4.3.1)  
• fansi      (1.0.4)   • R6         (2.5.1)   • methods    (4.3.1)  
• fastmap    (1.1.1)   • rappdirs   (0.3.3)   • stats      (4.3.1)  
• generics   (0.1.3)   • ratelimitr (0.4.1)   • tools      (4.3.1)  
• glue       (1.6.2)   • rlang      (1.1.1)   • utils      (4.3.1)  
• httr       (1.4.7)   • stringi    (1.7.12)    
── Not Installed ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
• ffsimulator  • ffpros  • ffopportunity  
tanho63 commented 9 months ago

1: ESPN API request failed with <Client error: (401) Unauthorized>

This suggests an issue with the ESPN_S2 and SWID values, try passing them as character strings directly to espn_connect?

thunderplayer17 commented 9 months ago

There it is that solved the problem. Was really getting thrown off with other functions working with the environment variables but that particular one did not. Appreciate the help.

tanho63 commented 9 months ago

Was really getting thrown off with other functions working with the environment variables but that particular one did not.

I think you may need to restart R after setting the .Renviron file. I should update that.