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

AttachUrl() public method

public AttachUrl ( long sheetId, Attachment attachment ) : Attachment
sheetId long
attachment Smartsheet.Api.Models.Attachment
return Smartsheet.Api.Models.Attachment
        public virtual Attachment AttachUrl(long sheetId, Attachment attachment)
        {
            return this.CreateResource("sheets/" + sheetId + "/attachments", typeof(Attachment), attachment);
        }

Usage Example

        public virtual void TestAttachUrl()
        {
            server.setResponseBody("../../../TestSDK/resources/attachUrl.json");

            Attachment attachment = new Attachment.CreateAttachmentBuilder("http://www.google.com", AttachmentType.LINK)
                                    .SetName("Search Engine").SetDescription("A popular search engine").Build();
            Attachment newAttachment = sheetAttachmentResource.AttachUrl(56545654, attachment);

            Assert.IsTrue(newAttachment.AttachmentType == AttachmentType.LINK);
            Assert.IsTrue(newAttachment.CreatedAt.Value.ToUniversalTime() == DateTime.Parse("2013-02-28T21:52:40-08:00").ToUniversalTime());
            Assert.IsTrue(newAttachment.Id == 1205473673275268);
            Assert.IsTrue(newAttachment.Description == "A popular search engine");
            Assert.IsTrue(newAttachment.Name == "Search Engine");
            Assert.IsTrue(newAttachment.Url == "http://google.com");
        }