diff --git a/Day-14/examples/create-jira.py b/Day-14/examples/create-jira.py new file mode 100644 index 00000000..e9618ad0 --- /dev/null +++ b/Day-14/examples/create-jira.py @@ -0,0 +1,54 @@ +# This code sample uses the 'requests' library: +# http://docs.python-requests.org +import requests +from requests.auth import HTTPBasicAuth +import json + +url = "https://veeramallaabhishek.atlassian.net/rest/api/3/issue" + +API_TOKEN = "" + +auth = HTTPBasicAuth("", API_TOKEN) + +headers = { + "Accept": "application/json", + "Content-Type": "application/json" +} + +payload = json.dumps( { + "fields": { + "description": { + "content": [ + { + "content": [ + { + "text": "My first jira ticket", + "type": "text" + } + ], + "type": "paragraph" + } + ], + "type": "doc", + "version": 1 + }, + "project": { + "key": "AB" + }, + "issuetype": { + "id": "10006" + }, + "summary": "First JIRA Ticket", + }, + "update": {} +} ) + +response = requests.request( + "POST", + url, + data=payload, + headers=headers, + auth=auth +) + +print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": "))) \ No newline at end of file diff --git a/Day-14/examples/list_projects.py b/Day-14/examples/list_projects.py new file mode 100644 index 00000000..93ecf2ca --- /dev/null +++ b/Day-14/examples/list_projects.py @@ -0,0 +1,28 @@ +# This code sample uses the 'requests' library: +# http://docs.python-requests.org +import requests +from requests.auth import HTTPBasicAuth +import json + +url = "https://veeramallaabhishek.atlassian.net/rest/api/3/project" + +API_TOKEN="" + +auth = HTTPBasicAuth("", API_TOKEN) + +headers = { + "Accept": "application/json" +} + +response = requests.request( + "GET", + url, + headers=headers, + auth=auth +) + +output = json.loads(response.text) + +name = output[0]["name"] + +print(name) \ No newline at end of file