Using python's requests module, using redmine's API Register your ticket.
An example using python-redmine is easy to find, There aren't many things that use requests, if you do it like you do with curl I stumbled, so I wrote it in the hope that someone else wouldn't stumbled.
After registering the ticket, use that ticket as the parent ticket and make child tickets one after another I wanted to register, but with the above library, after ticket registration Because the response returns as a Boolean value Because the registered ticket ID could not be obtained. (Please tell me who can do it!)
--API key is ready Anyway, it is necessary when registering a ticket using the API, so Let's prepare. --requests are already installed You can also see how to import. I know how to use it.
The header information is stored in a variable called myheaders as follows.
myheaders = {
'Content-Type': 'application/json',
'X-Redmine-API-Key': 'API key'
}
Input example
myheaders = {
'Content-Type': 'application/json',
'X-Redmine-API-Key': 'asdfghjklzxcvbnm'
}
payload = {
"issue": {
"project_id":Project ID,
"subject": "Ticket subject",
"status_id":Status ID,
"tracker_id":Tracker ID,
"parent_issue_id": "If there is a ticket you want to use as a parent ticket, its ticket ID",
"due_date": "Due date (2017-01-01))",
"description": "#Overview\n You can start a new line with backslash n.",
"custom_fields": [
{"id":Custom field ID, "value": "Value you want to register", "name": "Custom field name"},
{"id":Custom field ID, "value": ["In one field", "When there are multiple values you want to register", "Divide like this"], "name": "Custom field name"}
]
}
}
Input example
payload = {
"issue": {
"project_id": 10,
"subject": "Ticket subject",
"status_id": 15,
"tracker_id": 8,
"parent_issue_id": "10000",
"due_date": "2017−01−01",
"description": "#Overview\n You can start a new line with backslash n.",
"custom_fields": [
{"id": 1, "value": "pumpkin", "name": "Favorite vegetables"},
{"id": 2, "value": ["D", "F","G","H"], "name": "Favorite size"}
]
}
}
Register your ticket as follows!
redmineurl = 'http://URL of redmine'
requests.post(redmineurl,headers=myheaders,data=json.dumps(payload))
Recommended Posts