Hey @sgript! I see a few mistakes in your script, both in the GraphQL query you're running, as well as in how you're running it. The GraphQL Query that you want in order to list repository vulnerability alerts off of a single repo should look something like this: query repoVulns($owner:String!, $name:String!){
repository(owner:$owner, name:$name) {
vulnerabilityAlerts(first:10) {
nodes {
id
}
}
}
} In addition, it looks like you're passing the wrong data in with `data=json.dumps(payload)`, which seems to be a variable that only has some headers in it. I went ahead and made the changes, and I think this shoud work: import os
import requests
import json
url = 'https://api.github.com/graphql'
query = """
query repoVulns($owner:String!, $name:String!){
repository(owner:$owner, name:$name) {
vulnerabilityAlerts(first:10) {
nodes {
id
}
}
}
}
"""
variables = """
{"owner": "owner", "name": "name"}
"""
api_token = os.environ['bearer_token']
headers = {'Authorization': 'Bearer %s' % api_token, 'Accept': 'application/vnd.github.vixen-preview+json'}
r = requests.post(url=url, json={'query': query, 'variables': variables}, headers=headers)
print (r.text) You'll have to change the owner and the name to the Repository owner and name that you're trying to look up, but I think this should work! Let me know!
... View more