Insert Comments in DOCX with NET REST API

This topic entails the process to insert comments in DOCX with NET REST API. We will use Aspose.Words for .NET Cloud SDK to add a Comment into Word Document with C# Low Code API. You will obtain all the details to set the development environment and follow the given steps and C# REST API Code.


Steps to Insert Comments into Word Document with NET REST API

  1. Set Client ID and Client Secret for the API to add Comments in a Word file
  2. Create an object of the WordsAPI class with your client account credentials
  3. Create an object of the CommentInsert by providing the comment start and end range
  4. Create a request to add comments using an instance of the InsertCommentOnlineRequest by providing the file name
  5. Insert the Comments in the Word document online using the InsertComment method
  6. Download the generated file from the cloud using the stream inside the response.Documents dictionary
  7. Save the downloaded file stream as DOCX file on the disk

The aforementioned steps explain how to insert comments into Word Document with NET REST API. We will commence the process by initializing the WordsApi class instance using the ClientSecret and ClientId, which is then followed by creating the InsertComment class instance by setting the range for comment start and range. We will then create the InsertCommentOnlineRequest request and use the InsertCommentOnline to obtain the DOCX file stream with added comments. Finally, we will save the file stream with added comments on the disk as DOCX file.

Code to Add Comments in Word Document with NET REST API

This sample code demonstrates the process to create comments in DOCX with C# Low Code API. The CommentInsert class exposes the properties to set the range for comments start and end, comment initials, author and text. You can add multiple comments inside the document as well. The file name that we will set for the requesInsertCommentOnlineRequest, will be used to extract the respective document file stream from the response object.

In this topic, we have learned to add comments in Word document with NET REST API. If you are looking to create a Word Document, refer to the article on how to create a Word File with NET REST API.