Create a ticket using command line cURL


I’m using an example I found as a template which creates a parameter file then passes it through curl


id: ticket/new
Subject: Test Ticket
Text: Ticket Created
Queue: myQueue

curl command line:

curl --data-urlencode content@param.file https://server/REST/1.0/ticket/new?user=user&pass=pass

I keep getting the error Could not create ticket. Queue not set

I’ve seen posts stating that the queue name must be the last paramter but it really doesn’t matter where it is in this file.

Has anyone successfully done this?

OK, I’ll answer my own problem in the hope others may benefit.

It turns out that I was doing nothing wrong except the very last line in the parameter file must be line feed terminated (Unix flavour) rather than the carriage return/line feed you get when creating the file on the fly using echo commands.

I wrote a quick program in C to add a line with said terminator and hey-presto !! Success.

PS It also turns out you can use the -F format of the command as well
curl -F “content=<param.file” etc…