API Post Subject, Project, Tracer and Status cannot be blank
Added by David Costa over 3 years ago
I'm trying to develop a python script with the API and I get the following error:
' <errors type="array"><error>Subject cannot be blank</error><error>Project cannot be blank</error><error>Tracker cannot be blank</error><error>Status cannot be blank</error></errors>'
My code is the following:
payload_issue_xml = ' ' \
'<issue>' \
'<project_id>' + str(project_id) '</project_id>' \ '<tracker_id>' + str(tracker_id)'</tracker_id>' \ '<priority_id>' + str(priority_id)+'</priority_id>' \ '<status_id>' + "1" + '</status_id>' \ '<subject>' +subject +'</subject>' \ '<due_date>' +due_date +'</due_date>' \ '<done_ratio>' + str(done_ratio) +'</done_ratio>' \ '</issue>'
r_issue = requests.post(url, params=payload_issue_xml)
Replies (2)
RE: API Post Subject, Project, Tracer and Status cannot be blank - Added by Bernhard Rohloff over 3 years ago
FYI there's a python library which could make your life much easier.
https://python-redmine.com/
RE: API Post Subject, Project, Tracer and Status cannot be blank - Added by DAVID CARVALHO over 3 years ago
David Costa wrote:
I'm trying to develop a python script with the API and I get the following error:
' <errors type="array"><error>Subject cannot be blank</error><error>Project cannot be blank</error><error>Tracker cannot be blank</error><error>Status cannot be blank</error></errors>'
My code is the following:
payload_issue_xml = ' ' \
'<issue>' \
'<project_id>' + str(project_id) '</project_id>' \ '<tracker_id>' + str(tracker_id)'</tracker_id>' \ '<priority_id>' + str(priority_id)+'</priority_id>' \ '<status_id>' + "1" + '</status_id>' \ '<subject>' +subject +'</subject>' \ '<due_date>' +due_date +'</due_date>' \ '<done_ratio>' + str(done_ratio) +'</done_ratio>' \ '</issue>'r_issue = requests.post(url, params=payload_issue_xml)
As you are building the xml, try to start the issue with a xml tag.
payload_issue_xml = '<?xml version="1.0" encoding="UTF-8"?>' \ '<issue>' \ '<project_id>' + str(project_id) '</project_id>' \ '<tracker_id>' + str(tracker_id)'</tracker_id>' \ '<priority_id>' + str(priority_id)+'</priority_id>' \ '<status_id>' + "1" + '</status_id>' \ '<subject>' +subject +'</subject>' \ '<due_date>' +due_date +'</due_date>' \ '<done_ratio>' + str(done_ratio) +'</done_ratio>' \ '</issue>' r_issue = requests.post(url, params=payload_issue_xml)