I am trying to use GitHub's JSON API to pull in a list of all pull requests that contain assignees (so I can send them a message to resolve their pull requests).
I feel like I am close with the following code, but maybe I am not parsing the JSON correctly? any help would be appreciated.
import requests
url = "https://api.github.com/repos/<repo>/<repoguide>/pulls?"
payload = {}
headers = {
'Authorization': 'Bearer <mastertoken>',
'Accept': 'application/vnd.github.v3+json',
'page': 'page=5&per_page=100'
}
response = requests.request("GET", url, headers=headers, data = payload)
response = requests.get(url).json()
for obj in response:
assignees = obj['assignees']
for assignee in assignees :
name = assignee['login']
url = obj['html_url']
print('/md Hello {0}, there is a GitHub issue that needs your attention. For more information see [here]({1}).'.format(name,url))
Error:
assignees = obj['assignees']
TypeError: string indices must be integers
I don't understand what this error means or how to resolve it. Is it pulling a string vs dictionary? Sorry, this is my first time writing code.