Skip to content

Commit

Permalink
Request specific version of Github API as recommended
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwager committed Sep 27, 2016
1 parent 73e3c72 commit 1b412dc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/gitem/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ def __init__(self, oauth2_token=None, requester=requests.request):
self.oauth2_token = oauth2_token
self.requester = requester

# https://developer.github.com/v3/media/#request-specific-version
self.headers = {
"Accept": "application/vnd.github.v3+json",
}

def call(self, method, url, params=None):
"""
Make a Github developer API call
Expand All @@ -72,7 +77,7 @@ def call(self, method, url, params=None):
if self.oauth2_token:
params["access_token"] = self.oauth2_token

response = self.requester(method, url, params=params)
response = self.requester(method, url, params=params, headers=self.headers)

if response.status_code != requests.codes.OK:
raise ApiCallException(response.status_code, response.json())
Expand Down

0 comments on commit 1b412dc

Please sign in to comment.