z4r / python-rtkit

Python Api for Request Tracker's REST interface
http://z4r.github.com/python-rtkit/
Other
68 stars 44 forks source link

Can't create links between tickets #26

Closed molmos closed 11 years ago

molmos commented 11 years ago

I'm trying to use your module to create a ticket and then link it to a previous ticket. I can successfully create the ticket, but cannot create a link to a specific previous ticket. When I go to create the link, instead of linking the new ticket to the specified ticket, it creates a link to the first RT ticket created (ticket id = 1). Below is the code I'm using to create the link:

# Convert args to strings
child = 23
child = str(child)
parent = 20
parent = str(parent)
link_url = 'ticket/' + child + '/links'

# Create content for ticket payload
content = ''
content = { 
    'content': {
        'DependedOnBy': parent,
    }   
}   

# Connect to RT
resource = RTResource(rt_url, rt_user, rt_pass, CookieAuthenticator)

# Try to link tickets
try:
    response = resource.post(path=link_url, payload=content)
    logger.info(response.parsed)

except RTResourceError as e:
    logger.error(e.response.status_int)
    logger.error(e.response.status)
    logger.error(e.response.parsed)
z4r commented 11 years ago

Could you paste your output? This is mine and it seems correct :

[DEBUG] POST ticket/225/links
[DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'Accept': 'text/plain'}
[DEBUG] 'content=DependedOnBy: 247'
[INFO] POST
[INFO] http://rt.easter-eggs.org/demos/stable/REST/1.0/ticket/225/links
[DEBUG] HTTP_STATUS: 200 OK
[DEBUG] 'RT/4.0.5-116-g591e06a 200 Ok\n\n# Links for ticket 225 updated.\n\n'
[DEBUG] RESOURCE_STATUS: 200 Ok
[INFO] [[]]
[INFO] [[]]

you could see the ticket here: http://rt.easter-eggs.org/demos/stable/Ticket/Display.html?id=225

molmos commented 11 years ago

Below is the output:

[DEBUG] POST ticket/971/links [DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'Accept': 'text/plain'} [DEBUG] 'content=DependedOnBy: 970' [INFO] POST [INFO] http://ltwmolmos-vm/rt/REST/1.0/ticket/971/links [DEBUG] HTTP_STATUS: 200 OK [DEBUG] 'RT/3.8.7 200 Ok\n\n# Links for ticket 971 updated.\n\n' [DEBUG] RESOURCE_STATUS: 200 Ok [INFO] [[]] [INFO] [[]]

The output from the terminal looks fine. However when I go to check the RT web interface, I see that the links for ticket 971 have been updated but instead of being linked to 970, the new ticket (971) is linked to 1. I'm using RT 3.8.7, not sure if that matters.

z4r commented 11 years ago

Unfortunately it is a bug in version 3.8 of RT. I tried with another lib:

>>> import requests
>>> s = requests.session()
>>> data = {'user': 'john.foo', 'pass': 'john.foo'}
>>> s.post('http://rt.easter-eggs.org/demos/oldstable/REST/1.0/', data)
<Response [200]>
>>> r = s.post('http://rt.easter-eggs.org/demos/oldstable/REST/1.0/ticket/9/links', data='content=DependsOn: 8')
>>> r.text
u'RT/3.8.HEAD 200 Ok\n\n# Links for ticket 9 updated.\n\n'

And it modified tkt 9 linking tkt 1. With ver>=4.0 everything works fine.

I'll put a warning note on the docs, Thx