Created
February 22, 2018 03:24
-
-
Save mohankumargupta/061fa50ce6c8ac8b620bf69a084ffcfa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
headers = {'Authorization': 'Bearer 49beba867bca3b08df1252f837197b27ab529166'} | |
query_graphql = ''' | |
query { | |
repository(owner: "mohankumargupta", name: "raspberrypi-ansible") { | |
ref(qualifiedName: "master") { | |
target { | |
... on Commit { | |
history(first: 1) { | |
edges { | |
node { | |
oid | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
} | |
''' | |
query = 'query { viewer { name }}' | |
query_json = json.dumps({"query": query_graphql.replace('\n', '')}) | |
print(query_json) | |
response = requests.post( | |
'https://api.github.com/graphql', | |
query_json, | |
headers=headers) | |
response_json = response.json() | |
ref = response_json["data"]["repository"]["ref"] | |
print(ref["target"]["history"]["edges"][0]["node"]["oid"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment