Insert Comments in DOCX with NET REST API

This tutorial walks you through inserting comments into a DOCX file using the .NET REST API. By employing Aspose.Words for .NET Cloud SDK, you’ll learn how to add a comment to a Word document with the C# Low Code API. Follow the detailed steps to set up your development environment and execute the provided C# REST API code.

Prerequisite

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 example illustrates how to create comments in a DOCX file using the C# Low Code API. The CommentInsert class lets you specify the comment’s start and end range, initials, author, and text, and you can insert multiple comments throughout the document. By providing the file name in the requesInsertCommentOnlineRequest, the API extracts the corresponding document stream from the response object.

Throughout this guide we’ve shown you how to add comments in a Word document using the NET REST API. When you’re ready to generate a new Word file, check out our step‑by‑step tutorial on create a Word File with NET REST API.

 English