Skip to content

Instantly share code, notes, and snippets.

@sht
Last active January 25, 2022 13:29
Show Gist options
  • Save sht/821d9805a85b4673be8507342de240db to your computer and use it in GitHub Desktop.
Save sht/821d9805a85b4673be8507342de240db to your computer and use it in GitHub Desktop.
How to approve Github pull request using access token?

How to approve Github pull request using access token?

CURL:

curl -s -H "Authorization: token ghp_BWuQzbiDANEvrQP9vZbqa5LHBAxxIzwi2gM7" \
 -X POST -d '{"event":"APPROVE"}' \
 "https://api.github.com/repos/tech-security/chatbot/pulls/4/reviews"

Python Code:

import requests

headers = {
    'Authorization': 'token ghp_BWuQzbiDANEvrQP9vZbqa5LHBAxxIzwi2gM7',
}

#data = '{"body":"Some Comments", "event":"APPROVE"}'
#data = '{"body":"Some Comments"}'
data = '{"event":"APPROVE"}'

response = requests.post('https://api.github.com/repos/tech-security/chatbot/pulls/4/reviews', headers=headers, data=data)

print (response.json())

Note: above github token is dummy, so don't freak out please! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment