How to update a pull request through Github API

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 05:33:31

问题


I want to update the title of a pull request and performing the below to achieve it :- (followed this doc https://developer.github.com/v3/pulls/#update-a-pull-request)

data = {"title": "New title"}
url='https://hostname/api/v3/repos/owner/repo/pulls/80'
token = 'my-token'
headers = {'Content-type': 'application/json', 'Accept': 'application/json', 'Authorization': 'token %s' % token}
resp = requests.patch(url, data=json.dumps(data), headers=headers)

print resp.json()

What am I missing ? Please help.


回答1:


The following worked for me:

import requests

token = "my-token"
url = "https://api.github.com/repos/:owner/:repo/pulls/:number"
payload = {
    "title": "New title"
}

r = requests.patch(url, auth=("username", token), json=payload)

print r.json()


来源:https://stackoverflow.com/questions/43081609/how-to-update-a-pull-request-through-github-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!