Create a RT ticket using python-rtkit with RESOURCE_STATUS: 401 Required credentials

I'm new here. This is the same question as this one, but I have not received an answer, so I am posting it again: how to create a ticket in rt using python-rtkit

I tried both CookieAuthenticator, and BasicAuthenticatorcreate or read the ticket, but I still get the same error:

`RT/3.8.13 401 Credentials required` 

When I load the url directly in the browser: http://ticket.corp.kk.net/REST/1.0/ticket/214560?user=user&pass=pass , I get the ticket contents in the browser.

I even tried a command wgetto retrieve a single ticket content, as shown below, using a cookie, and it works well:

  • manually save the cookie value in a file coookie.txt:

    RT_SID_kk.net.80=5a1c1eb207c4e2ef5af726e98d751a08
    
  • run the following command:

    wget -O ticketContent.txt --keep-session-cookies --save-cookies cookies.txt 'http://ticket.corp.kk.net/REST/1.0/ticket/220680/show?format=l&user=user&pass=pass'
    

ticketContent.txt, cookie .

CookieAuthentication rtkit python script.

2 , , - . .

0
1

, python RT.

  • install lib. http://docs.python-requests.org/en/latest/user/install/#install
  • RT

    #!/usr/bin/python -u
    import requests,logging
    
    logging.basicConfig(level=logging.DEBUG)
    post_data = """
    id: ticket/new
    Queue: myqueue
    Subject: Test Ticket creation in RT with Python
    Text: Wow ticket is created :-D . 
    """
    payload = {'user': 'user', 'pass': 'password','content':post_data}
    ticket_creation_reusult = requests.post("http://ticket.corp.kk.net/rt3/REST/1.0/ticket/new", payload)
    
    logging.debug(ticket_creation_reusult.text)
    

:

INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1):  ticket.corp.kk.net
DEBUG:requests.packages.urllib3.connectionpool:"POST /rt3/REST/1.0/ticket/new     HTTP/1.1" 200 None
DEBUG:root:RT/3.8.13 200 Ok
# Ticket 221173 created.

, , , .:-)

0

Source: https://habr.com/ru/post/1598702/


All Articles