[rt-users] Attachments using REST in VB.NET

Todd Burton todd.burton at tbaytel.com
Thu May 26 10:42:03 EDT 2011


Hi,

I am currently developing an application using VB.NET in which I am accessing RT using the REST interface. So far, I have been able to successfully create tickets and modify their history by referencing the Request Tracker Wiki. However, I have not been able to add an attachment to a ticket. I have done extensive research online, but so far I have not been able to find any working examples in VB.NET. To actually upload the data to RT, I use System.Net.WebClient. The following VB.NET code does the important work:

Dim Client As New System.Net.WebClient
Dim postBytes As Byte() = System.Text.Encoding.ASCII.GetBytes(postString)
Client.UploadData(URL, "POST", postBytes)

A simplified version of my URL is as follows:
"..//REST/1.0/ticket/" + ticketNumber + "/comment?user=" + userName + "&pass=" + password

Finally, an example of the content that I post is:
postString = "content=Text: RT Test" + vbLf + "Action: Comment" + vbLf + "Attachment: examplefile.jpg" + vbLf + "attachment_1="

As you can see, the postString is converted to bytes and then uploaded to the RT server. However, I do not know where or how I should be posting the raw attachment itself. The RT wiki mentions that it should be in a variable "attachment_1," which I added to the postString variable, but I am not sure what the next step should be. Should the file be converted into bytes and appended to the postBytes variable? I attempted something like this but I received an error saying that no attachment was found for examplefile.jpg.

Thanks for your help!
Todd Burton

________________________________
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this email. Please notify the sender immediately by e-mail if you have received this email by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bestpractical.com/pipermail/rt-users/attachments/20110526/c7f1bb1f/attachment.htm>


More information about the rt-users mailing list