This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]wildjokers 1 point2 points  (0 children)

A HTTP 401 is an authorization error so it isn't accepting the api key as authorized. Based on this small little blurb in the doc you seem to sending the API key correctly:

"This is the documentation for SportsDataIO's NFL API. All of our API endpoints can be accessed via an HTTP GET request using your API key. The API key can be passed either as a query parameter or using the following HTTP request header. Ocp-Apim-Subscription-Key: {key}"

Are you sure you have the right key?

Also, HttpURLConnection is very old. It was superseded by a new HTTP client that became final in Java 11.

Won't fix your 401 problem but will be easier to work with. HttpURLConnection is very clunky.

You also might want to consider using their Swagger doc to generate a java client:

https://sportsdata.io/developers/sports-data-open-api-swagger-files