@@ -19,18 +19,21 @@ class ApiScoreboards {
1919 ApiScoreboard forDate (LocalDate date ) {
2020 String url = "https://stats.nba.com/stats/scoreboardv3?LeagueID=00&GameDate=" + date ;
2121
22- HttpHeaders headers = new HttpHeaders ();
23- headers .set ("Referer" , "https://www.nba.com/" );
24- headers .set ("User-Agent" , "Mozilla/5.0 (X11; Linux x86_64)" );
25-
26- HttpEntity <Void > entity = new HttpEntity <>(headers );
27-
28- return rest .exchange (url , HttpMethod .GET , entity , ApiScoreboardWrapper .class ).getBody ().getScoreboard ();
22+ return rest .exchange (url , HttpMethod .GET , entityWithNbaHeaders (), ApiScoreboardWrapper .class ).getBody ().getScoreboard ();
2923 }
3024
3125 public ApiBoxscoreGame boxscoreForGame (String gameId ) {
3226 String url = "https://cdn.nba.com/static/json/liveData/boxscore/boxscore_" + gameId + ".json" ;
3327
34- return rest .getForObject (url , ApiBoxscore .class ).getGame ();
28+ return rest .exchange (url , HttpMethod .GET , entityWithNbaHeaders (), ApiBoxscore .class ).getBody ().getGame ();
29+ }
30+
31+ private static HttpEntity <Void > entityWithNbaHeaders () {
32+ HttpHeaders headers = new HttpHeaders ();
33+ headers .set ("Origin" , "https://www.nba.com/" );
34+ headers .set ("Referer" , "https://www.nba.com/" );
35+ headers .set ("User-Agent" , "Mozilla/5.0 (X11; Linux x86_64)" );
36+
37+ return new HttpEntity <>(headers );
3538 }
3639}
0 commit comments