z4r / python-rtkit

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

Unable to create new ticket #40

Open mgaulton opened 9 years ago

mgaulton commented 9 years ago

Using RT 4.2 with RTIR. Still getting a blank Queue when submitting a new ticket. Searching for a ticket gets the correct result. Not sure what i'm doing wrong here. Code follows result block.

[DEBUG] POST ticket/new [DEBUG] {'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8', 'Accept': 'text/plain'} [DEBUG] 'content=Queue: IST-Security\nText: My+useless%0A+text+on%0A+three+lines.\nSubject: New Ticket Test' [INFO] POST [INFO] http://rt.uwaterloo.ca/REST/1.0/ticket/new [DEBUG] HTTP_STATUS: 200 OK [DEBUG] 'RT/4.2.9-43-gd7c0cfd 200 Ok\n\n# Required: id, Queue\n\nid: ticket/new\nQueue: \nRequestor: issminion\nSubject: \nCc:\nAdminCc:\nOwner: \nStatus: new\nPriority: \nInitialPriority: \nFinalPriority: \nTimeEstimated: 0\nStarts: 2014-12-02 10:23:19\nDue: \nAttachment: \nText: \n\n' [DEBUG] RESOURCE_STATUS: 200 Ok [INFO] [[('id', 'ticket/new'), ('Queue', ''), ('Requestor', 'issminion'), ('Subject', ''), ('Cc', ''), ('AdminCc', ''), ('Owner', ''), ('Status', 'new'), ('Priority', ''), ('InitialPriority', ''), ('FinalPriority', ''), ('TimeEstimated', '0'), ('Starts', '2014-12-02 10:23:19'), ('Due', ''), ('Attachment', ''), ('Text', '')]] [INFO] [[('id', 'ticket/new'), ('Queue', ''), ('Requestor', 'issminion'), ('Subject', ''), ('Cc', ''), ('AdminCc', ''), ('Owner', ''), ('Status', 'new'), ('Priority', ''), ('InitialPriority', ''), ('FinalPriority', ''), ('TimeEstimated', '0'), ('Starts', '2014-12-02 10:23:19'), ('Due', ''), ('Attachment', ''), ('Text', '')]]

!/usr/bin/env python

import sys import re import smtplib import subprocess import os import rt import ConfigParser import time from rtkit.resource import RTResource from rtkit.authenticators import QueryStringAuthenticator from rtkit.errors import RTResourceError

from rtkit import set_logging import logging set_logging('debug') logger = logging.getLogger('rtkit')

config = ConfigParser.RawConfigParser() config.read(os.path.expanduser('~/.rtrcp'))

notkit rtpoint = "https://{0}/REST/1.0/".format(config.get('rt','hostname'))

rtuser = config.get('rt','username') rtpass = config.get('rt','password') rthost = config.get('rt','hostname')

resource = RTResource('http://{0}/REST/1.0/', '{1}', '{2}', BasicAuthenticator).format(rthost,rtuser,rtpass)

try: resource = RTResource('http://rt.uwaterloo.ca/REST/1.0/', rtuser, rtpass, QueryStringAuthenticator)

except: print rtuser, rtpass, rthost print "Oops." sys.exit(0)

content = { 'content': { 'Queue': 'IST-Security', 'Subject': 'New Ticket Test', 'Text': 'My useless\ntext on\nthree lines.', } } try: response = resource.post(path='ticket/new', 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 9 years ago

Could you try to retrieve a tkt?

mgaulton commented 9 years ago

Retrieving a ticket using the below works. Hence my confusion. :)

!/usr/bin/env python

import sys import re import smtplib import subprocess import os import rt import ConfigParser import time from rtkit.resource import RTResource from rtkit.authenticators import QueryStringAuthenticator from rtkit.errors import RTResourceError

from rtkit import set_logging import logging set_logging('debug') logger = logging.getLogger('rtkit')

config = ConfigParser.RawConfigParser() config.read(os.path.expanduser('~/.rtrcp'))

notkit rtpoint = "https://{0}/REST/1.0/".format(config.get('rt','hostname'))

rtuser = config.get('rt','username') rtpass = config.get('rt','password') rthost = config.get('rt','hostname')

resource = RTResource('http://{0}/REST/1.0/', '{1}', '{2}', BasicAuthenticator).format(rthost,rtuser,rtpass)

try: resource = RTResource('http://rt.uwaterloo.ca/REST/1.0/', rtuser, rtpass, QueryStringAuthenticator)

except: print rtuser, rtpass, rthost print "Oops." sys.exit(0) try: response = resource.get(path='ticket/386422') for r in response.parsed: for t in r: logger.info(t) except RTResourceError as e: logger.error(e.response.status_int) logger.error(e.response.status) logger.error(e.response.parsed)

z4r commented 9 years ago

Could you write here your logger output?

mgaulton commented 9 years ago

Can I message it to you offline, its got some info i'd rather not post publicly.

On 12/3/14, Andrea de Marco notifications@github.com wrote:

Could you write here your logger output?


Reply to this email directly or view it on GitHub: https://github.com/z4r/python-rtkit/issues/40#issuecomment-65456798

z4r commented 9 years ago

sure, contact me on skype: z4erre