Smartsheet.Api.Internal.SheetAttachmentResourcesImpl.AttachFile C# (CSharp) Method

AttachFile() public method

Attaches a file to the Sheet.

It mirrors To the following Smartsheet REST API method:
POST /sheets/{sheetId}/attachments

if any argument is null or empty string if there is any problem with the REST API request if there is any problem with the REST API authorization (access token) if the resource cannot be found if the REST API service is not available (possibly due To rate limiting) if there is any other error during the operation
public AttachFile ( long sheetId, string file, string fileType ) : Attachment
sheetId long the sheet Id
file string the file path
fileType string the file type
return Smartsheet.Api.Models.Attachment
        public virtual Attachment AttachFile(long sheetId, string file, string fileType)
        {
            return AttachFile("sheets/" + sheetId + "/attachments", file, fileType);
        }

Same methods

SheetAttachmentResourcesImpl::AttachFile ( string path, string file, string contentType ) : Attachment

Usage Example

        public virtual void TestAttachFile()
        {
            server.setResponseBody("../../../TestSDK/resources/attachWordFile.json");
            string file = @"..\..\..\TestSDK\resources\large_sheet.pdf";

            Attachment attachment = sheetAttachmentResource.AttachFile(56545654, file, "application/msword");

            Assert.IsTrue(attachment.AttachmentType == AttachmentType.FILE);
            Assert.IsTrue(attachment.CreatedAt == DateTime.Parse("2013-02-28T21:04:56-08:00"));
            Assert.IsTrue(attachment.Id == 4583173393803140);
            Assert.IsTrue(attachment.MimeType == "application/msword");
            Assert.IsTrue(attachment.Name == "ProgressReport.docx");
        }