Request Tracker (RT) REST API HTTP POST

2.4k Views Asked by At

I'm trying to create a ticket in RT via the REST API. The wiki provides the guidance on how RT REST wiki

The instructions are:

Ticket Create Edit To create a new ticket: post on /REST/1.0/ticket/new with a variable named "content",

containing "key: value" line by line, example:

Testing the new ticket section

id: ticket/new Queue: Requestor: Subject: Cc: <...> AdminCc: <...> Owner: <...> Status: <...> Priority: <...> InitialPriority: <...> FinalPriority: <...> TimeEstimated: <...> Starts: <...> Due: <...> Text: CF-: If there are any "special" characters (Umlauts, dash, ...?) in a custom field's name, you can still access it via its ID:

CF-$id: If you want to have a multiline Text, prefix every line with a blank.

Due: <...> Text: This is a multiline Text !!! CF-: The response should look like:

RT/4.0.6 200 Ok

Ticket 775 created.

I'm using VBA and I can create a ticket in the right queue with my code, but it doesnt accept any of the other fields I include in the request.

 Public Sub TestRT()

Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
URL = "https://[RT IP]/REST/1.0/ticket/new?user=root&pass=password"
objHTTP.Open "POST", URL, False
objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
objHTTP.SetRequestHeader "Content-type", "application/x-www-form-urlencoded"
RTContent = "Queue: Incidents&"
objHTTP.Send ("content=" & RTContent)
MsgBox objHTTP.ResponseText
End Sub

This works, with the & on the end of incidents.I've tried a lot of variations of the RTContent variable but just can't seem to get it to work. If I try RTContent = "Queue: Incidents&Subject: Test" The ticket gets created but with no subject.

I've looked on google, and although some people have asked the question around using VBA, the responses I've found point to just using another language. Unfortunately I need to get this working via VBA if possible.

Thanks

1

There are 1 best solutions below

0
On
RTContent = "Queue: Incidents" & vbLf & "Subject: New item2"

It was the linefeed that was missing. Now added, works fine.