Skip to content

Commit 70f5215

Browse files
add files for day-14
1 parent 4126860 commit 70f5215

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

Day-14/examples/create-jira.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This code sample uses the 'requests' library:
2+
# http://docs.python-requests.org
3+
import requests
4+
from requests.auth import HTTPBasicAuth
5+
import json
6+
7+
url = "https://veeramallaabhishek.atlassian.net/rest/api/3/issue"
8+
9+
API_TOKEN = ""
10+
11+
auth = HTTPBasicAuth("", API_TOKEN)
12+
13+
headers = {
14+
"Accept": "application/json",
15+
"Content-Type": "application/json"
16+
}
17+
18+
payload = json.dumps( {
19+
"fields": {
20+
"description": {
21+
"content": [
22+
{
23+
"content": [
24+
{
25+
"text": "My first jira ticket",
26+
"type": "text"
27+
}
28+
],
29+
"type": "paragraph"
30+
}
31+
],
32+
"type": "doc",
33+
"version": 1
34+
},
35+
"project": {
36+
"key": "AB"
37+
},
38+
"issuetype": {
39+
"id": "10006"
40+
},
41+
"summary": "First JIRA Ticket",
42+
},
43+
"update": {}
44+
} )
45+
46+
response = requests.request(
47+
"POST",
48+
url,
49+
data=payload,
50+
headers=headers,
51+
auth=auth
52+
)
53+
54+
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

Day-14/examples/list_projects.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This code sample uses the 'requests' library:
2+
# http://docs.python-requests.org
3+
import requests
4+
from requests.auth import HTTPBasicAuth
5+
import json
6+
7+
url = "https://veeramallaabhishek.atlassian.net/rest/api/3/project"
8+
9+
API_TOKEN=""
10+
11+
auth = HTTPBasicAuth("", API_TOKEN)
12+
13+
headers = {
14+
"Accept": "application/json"
15+
}
16+
17+
response = requests.request(
18+
"GET",
19+
url,
20+
headers=headers,
21+
auth=auth
22+
)
23+
24+
output = json.loads(response.text)
25+
26+
name = output[0]["name"]
27+
28+
print(name)

0 commit comments

Comments
 (0)