REST and attachments

I’m using RT 3.8.4. I’m interfacing with RT using a website written in
C#. After struggling a bit, I finally figured out how to retrieve
ticket information, edit tickets, and create new tickets. Now I’m just
trying to figure out how to incorporate attachments.

I’m creating a ticket with the following post in C#:

Content=id: ticket/new\nsubject: new ticket\nqueue:
Automation\nrequestor: user@domain.com\nText: This is the text of the
ticket\rA second line of text in the ticket

When I attempt to create a ticket with an attachment, I tried the
following:

Content=id: ticket/new\nsubject: new ticket\nqueue:
Automation\nrequestor: user@domain.com\nText: This is the text of the
ticket\rA second line of text in the ticket\nAttachment:
d:\Inetpub\RT-REST\Files\Penguins.jpg

I received the following response:

RT/3.8.4 409 Syntax Error

Ticket 70 created.

attachment: Unknown field.

id: ticket/new

subject: new ticket

requestor: user@domain.com

Has anyone had any success creating a ticket with an attachment using
REST?

What about commenting on an existing ticket and adding an attachment
using REST?

I know I can get around this by sending an email with the attachment,
but that seems like a round-about way of doing things.

Retrieving the attachments seems fairly straight forward, but I didn’t
really see anything with any specific details on creating an attachment
via REST.

Thanks.

Jennifer

Content=id: ticket/new\nsubject: new ticket\nqueue:
Automation\nrequestor: user@domain.com\nText: This is the text of the
ticket\rA second line of text in the ticket\nAttachment:
d:\Inetpub\RT-REST\Files\Penguins.jpg

RT doesn’t read local files and encode them for you. You have to send
the file contents. Also, I haven’t figured out how to create a ticket
with an attachment so what I do is create a ticket and then immediately
create a reply with the attachment.

If you can read ruby (and there’s no reason you can’t), have a look at
http://rubyforge.org/projects/rt-client/ which is a ruby library I wrote
that does a lot of the work for you, if you happen to be using ruby for
RT REST that is. But that code does create tickets and add attachments
to them.