感謝任何幫助 - 第一次使用Django和Github API。我有一個簡單的URL,可以通過回購請求的api請求獲得。我循環他們到我想要檢查的diff_url屬性。python請求庫到github api - 對相同url的不一致響應
在鉻瀏覽器中,它工作正常,我顯示拉的代碼差異的文本輸出。看着網絡流量,網絡呼叫正在向包含令牌的另一個URL發送302。
在隱身鑲邊以及捲曲中,我收到了404錯誤。
我使用github3.py來獲取拉模型,並請求(使用簡單身份驗證)嘗試從拉模型屬性訪問diff_url。
我在想爲什麼瀏覽器能夠正常工作,代碼和捲曲都不起作用。
這裏是Python代碼:
def getAllPullRequestsForRepo(self, repo_name):
''' Return pull request and tag object for repository
Github: Every pull request is an issue, but not every issue is a pull request
For each pull request = issue - get associated labels
'''
# TODO look at repo array to get repository (save as object)
repoOwner = self.org_name + '/' + repo_name
github = Github(self.username, self.password)
repository = github.get_repo(repoOwner)
pullDict = []
pulls = repository.get_pulls('all')
pullDatum = {}
for pull in pulls:
assigneeName = ''
assigneeLogin = ''
if pull.assignee:
assigneeName = pull.assignee.name
assigneeLogin = pull.assignee.login
pullDatum = {
'id': pull.id,
'assignee': assigneeName,
'assignee_login': assigneeLogin,
'title': pull.title,
'body': pull.body,
'state': pull.state,
'created': pull.created_at,
'diff_url': pull.diff_url,
'diff_content': '',
'issues_url': pull.issue_url,
'issues_content': '',
'commits_url': pull.commits_url,
'commits_content': '',
}
# Get the code differences and load into diff data
diff_url_data = requests.get(pull.diff_url, auth=(self.username, self.password))