CURL RT Rickets

Good Day

I am running a curl command to get the output of a ticket, however I am only getting the following output:

Date: Thu, 24 Oct 2019 14:17:36 GMT
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9
X-Frame-Options: ALLOW
Set-Cookie: RT_SID_Mitigate.443=143277858ea27760bec9d41df4831eda; path=/; HttpOnly
Content-Type: text/plain; charset=utf-8

My curl command is:
curl --insecure -I “https://rt03.rtserv.local/REST/1.0/ticket/62731/show\?user\=admin\&pass\=admin

Kind Regards

The -I curl flag: -I, --head Show document info only

Ah, my pebcak…

I am gettting a credentials required now although I am passing it in the curl…

1 Like

Figured it out, I was escaping the username and password.

I’d double check that they are the correct username/password, default RT is root/password

Would you know how to update the ticket status via curl?

I have the following python script but the “status: assigned” just doesn’t seem to be working.


try:
    rt_site = 'https://172.20.15.212/'
    user = 'admin'
    password = 'admin'

    content = ("CF-Comment: {}".format(comment) + '\n' +
               "CF-Allocated To: {}".format(loggedInUser) + '\n' +
               "CF-Resolution Feedback: {}".format(resolution_feedback) + '\n' +
               "Status: assigned"
              )

    payload = {'content': content}
    query = rt_site + ('REST/1.0/ticket/{}/edit').format(ticket_id)
    query = query + '?user=' + user + '&pass=' + password

    # send request
    r = requests.post(query, verify=False, params=payload)
    print(r.text)

    content2 = (("id: {}").format(ticket_id) + '\n' +
          "Action: comment" + '\n' +
          ("Text: {}").format(comment)
          )

    payload2 = {'content': content2}
    query2 = rt_site + ('/REST/1.0/ticket/{}/comment').format(ticket_id)
    query2 = query2 + '?user=' + user + '&pass=' + password
    r2 = requests.post(query2, verify=False, params=payload2)

So long as all your substituting is fine I feel the payload looks okay, is assigned a valid status in the web UI for the ticket you’re working on?

Yes it is.

How do I do this via curl?

The python just doesn’t seem to be working. :expressionless::sleepy::sleepy:

The Python work’d for me when I tested really quick, do you have a custom life cycle that makes assigned a valid status for your Queue?

Also if you’re going to be working on automating RT you may want to take a look at installing the REST2 API. I find that its easier to work with:

I think we do have a custom life cycle.

I have tried to change from Status: Assigned to status: resolved and that fails too…

I am trying to build something where one can click a webpage button and it calls a python script to resolve a new or assigned ticket.

does the lifecycle have a pathway from assigned to resolved?

regards

Garry