Skip to content
On this page

File Attachment-Related Code Samples

GetFileAttachments()

csharp
var req = new FileAttachmentDetailsRequestModel()
{
    TaskIDs = new List<object> { 1234567890 }
};

var api = new FileAttachmentsApi(myRestEndpointUrl);
var results = api.GetFileAttachments(req, apiKey, apiSecret, apiUsername, apiPassword);
if (results.IsSuccessful.Value)
{
    //do work...
}
else
{
    //handle error
}

InsertFileAttachments()

csharp
var req = new FileAttachmentInsertRequestModel()
{
    EnableLogging = false,
    FileAttachments = new List<object>
                    {
                        new FileAttachmentInsertModel()
                        {
                            TaskID = 1234567890,
                            FileBytes = System.IO.File.ReadAllBytes(@"C:\myAttachment.jpg"),
                            FileMimeType = "application/pdf",
                            FileName = "My File Attachment Test.pdf"
                        }
                    }
};

var api = new FileAttachmentsApi(myRestEndpointUrl);
var results = api.InsertFileAttachments(req, apiKey, apiSecret, apiUsername, apiPassword);
if (results.IsSuccessful.Value)
{
    //do work...
}
else
{
    //handle error
}