Change Properties of Word Document with NET REST API

This article entails how to change properties of Word document with NET REST API. We will use Aspose.Words for .NET Cloud SDK to add or update the Word document property with C# Low Code API. This article will guide you to add new custom property or update existing built-in or custom property using the property name and new value.


Steps to Edit Document Properties in Word with C# REST API

  1. Set Client ID and Client Secret for the API to modify Word properties
  2. Create an object of the WordsApi class using the client credentials
  3. Read the source Word file into the memory stream to modify its properties
  4. Create the DocumentPropertyCreateOrUpdate class object by providing the property value
  5. Create the CreateOrUpdateDocumentPropertyOnlineRequest object by setting the desired property
  6. Call the CreateOrUpdateDocumentPropertyOnline method to create or update the property
  7. Save the output Word file with the new property value

The aforementioned steps describe the process to modify document properties with C# REST API. Commence the process by creating the WordsApi class object followed by loading the source Word file into a memory stream. Later, use the DocumentPropertyCreateOrUpdate object to define the new property parameters, create the CreateOrUpdateDocumentPropertyOnlineRequest using the property value and property name, and finally call the CreateOrUpdateDocumentPropertyOnline object to add or update the property in the loaded Word file.

Code to Edit the Document Properties with C# Low Code API

This sample code demonstrates working with the Microsoft Word properties with C# Low Code API. When we create the CreateOrUpdateDocumentPropertyOnlineRequest object, we mention the destFileName which is the name of the resultant output file created on the Cloud. After processing the document property, use the same file name to download the output file for saving on the disk.

We have learned to edit document properties with C# Low Code API. To read comments from a Word file, refer to the following article: Read Comments in Word Document with NET REST API.