Smartsheet.Api.Internal.DiscussionCommentResourcesImpl.AddCommentWithAttachment C# (CSharp) Method

AddCommentWithAttachment() public method

Adds a Comment attached with an Attachment to a Discussion.

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

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 AddCommentWithAttachment ( long sheetId, long discussionId, Comment comment, string file, string fileType ) : Comment
sheetId long the id of the sheet
discussionId long the id of the discussion
comment Smartsheet.Api.Models.Comment Comment object
file string the file path
fileType string the file type
return Smartsheet.Api.Models.Comment
        public virtual Comment AddCommentWithAttachment(long sheetId, long discussionId, Comment comment, string file, string fileType)
        {
            return this.CreateResourceWithAttachment("sheets/" + sheetId + "/discussions/" + discussionId + "/comments", comment, "comment", file, fileType);
        }

Usage Example

Example #1
0
        public virtual void TestAddCommentWithAttachment()
        {
            string  file    = @"..\..\..\TestSDK\resources\wordFile.docx";
            Comment comment = new Comment.AddCommentBuilder("Please review the attached file.").Build();

            server.setResponseBody("../../../TestSDK/resources/addCommentWithAttachment.json");
            Comment newComment = commentResources.AddCommentWithAttachment(8357140688594820, 5773448686397316, comment, file, "application/msword");

            Assert.IsTrue(newComment.Id == 2570595675203460);
            Assert.IsTrue(newComment.CreatedBy.Name == "Eric Yan");
            Assert.IsTrue(newComment.Attachments[0].Id == 6130526026262404);
            Assert.IsTrue(newComment.Attachments[0].Name == "wordFile.docx");
            Assert.IsTrue(newComment.Attachments[0].AttachmentType == AttachmentType.FILE);
            Assert.IsTrue(newComment.Attachments[0].ParentId == 2570595675203460);

            //Will not be able to deserialize (wIll throw error) unless Attachment object is also updated.
            //Assset TO-DO
        }