python easyredmine create issue not working

263 views Asked by At

We are trying to make a simple request to create an issue using Easy redmine api (this should be really simple) we have tried from postman and also within pycharm via python code, we always recieve a 200 with the list of issues, but no 201 with ok for creation.

It seems that it doesnt care if we use POST, PUT or GET methods it always returns a 200 with the list of issues. Because of this we discard a problem within the user permissions or connection.

As no error management its being done in the interface (API) and returned as response it´s not posible to identify if we have any xml problem.

enter code here

def create_issue():
url = "http://domain.easyredmine.com/issues.xml"

payload = ""
headers = {
    'Content-Type': "application/xml",
    'Authorization': "Basic @token=",
    'Cache-Control': "no-cache",
    'Postman-Token': "@postman_token"
}
try:
    response = requests.request("POST", url, data=payload, headers=headers)
except Exception as e:
    print("Error", e)
print(response.text)

XML data

<issue>
    <project_id>test_01</project_id>
    <status_id>1</status_id>
    <priority_id>1</priority_id>
    <author_id> @author</author_id>
    <subject>issue subject</subject>
    <description>
        issue description
    </description>
    <start_date>2014-04-11</start_date>
    <due_date>2014-04-11</due_date>
    <estimated_hours>1.0</estimated_hours>
</issue>

As commented this should be really easy but we are hard stucked

Any help would be really appreciated

Thank you in advance.

1

There are 1 answers

0
Alberto J.E.G On

Well, nothing like fresh approach,

First of all I have changed to https or the url (yesterday for some reason this didnt work) but today it does and in https we are getting some usefull response information

For those trying to get more info you can use the url (you must be logged)

https://@yourdomain.easyredmine.com/issues.xml

In here you can get usefull information to build the xml payload such as what id has an specific project and how labels must be referenced.

capture XML issues List

For example using this xml with https call (POST)

<issue>
    <project_id>194</project_id>
    <priority>10</priority>
    <tracker>1</tracker>
    <author>Alberto Elvira</author>
    <subject>TEST ERM API</subject>
    <description>
       TEST ERM API from POSTMAN
    </description>
</issue>

Result Response ok

Hope this will help someone as I didnt saw any about this in Stack or googling. Basic but usefull info!

Thank you!