1

Where is this documented?

(I'd like to attach a file during cmd=new or cmd=edit)

For .NET see How do I upload file attachments using the XML API in .NET C# or VB.NET?

flag

3 Answers

1

This is documented under the "API" section of the "Advanced Help Topics" of the FogBugz help. To quote...

You can also upload an unlimited number of files (constrained only by the max upload limit on the web server).

File1, File2, File3, etc. To upload files, use the enctype="multipart/form-data" form type and you will need an additional argument nFileCount which contains the number of files (otherwise only the first one will upload).

For example, an html page which submits to the api to create a new case would look like this:

<form method="post"
    action="http://localhost/fb/api.asp"
    enctype="multipart/form-data"
>

    <input type=hidden name=cmd value=new />
    <input type=hidden
        name=token
        value="CCECOGMBRTPJLFUVFUAAGZCEIEYAC2"
    />
    <input type=file name=File1 />
    <input type="submit">
</form>
link|flag
This doesn't really answer the question since Michael was really looking for a way to submit the attachment in the xml. It's quite possible that a form is not being used. – Mike Sep 3 2010 at 18:39
As I read it, the question was "Where is this documented?" My answer may not be what Michael was looking for, but it is difficult to see how it does not answer the question posed. – James McLeod Sep 3 2010 at 21:08
1

I gave up trying to use the XML API when I discovered that you can email cases@yourdomain.fogbugz.com with the subject "Case ###" where ### is the ix of the case you wish to attach to.

Multiple attachments work. Each file needs to be < 10MB and the total works up to about 25MB with OnDemand.

Using C#, it takes about 10 lines of code to achieve this. It looks a bit like this (simplistic sample):

using System.Net.Mail;

...

String fromAddress = "michael@mydomain.com"; String toAddress = "cases@mydomain.fogbugz.com";

MailMessage message = new MailMessage(); message.From = new MailAddress(fromAddress); message.To.Add(new MailAddress(toAddress));

message.Subject = "Case " + ix.ToString(); foreach (path in attachmentPaths) { Attachment item = new Attachment(path); message.Attachments.Add(item); }

SmtpClient smtpClient = new SmtpClient("smtp.mymailserver.com", 25);

smtpClient.Credentials = new System.Net.NetworkCredential("user", "password"); smtpClient.Send(message);

link|flag
This works perfectly. Unless you get the case number wrong... in which case the information will be irrevocably attached to the wrong case, occasionally generating a new case as needed. – James McLeod Apr 27 2010 at 16:58
0

Or you can try the excellent wrapper ( in C#).

It contains the example on how to use the API to upload attachment.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.