Update All Fields in Word with C# REST API

Follow this article to update all fields in DOC with C# REST API. You will learn how to update field in Word with C# Low Code API using a .NET-based Cloud SDK. A complete process will be demonstrated, starting from loading the source Word file and finally downloading the updated Word file from the Cloud storage.

Prerequisite

Steps to Update Field in Word with C# RESTful Service

  1. Instantiate the Configuration object by setting the Client secret and ID for updating fields
  2. Create the WordsApi object using the above configuration
  3. Load the source Word file into a memory stream with some field data such as TOC in it
  4. Create the UpdateFieldsOnlineRequest class to create a request for the loaded Word file
  5. Invoke the UpdateFieldsOnline() method using the above request object
  6. Parse the API response and access the returned stream
  7. Save the output stream as a file on the disk

The above steps explain how to update all fields in Word with C# REST API. Read the source Word file into the memory stream, create a request object, define the destination file name, and call the UpdateFieldsOnline() method to update fields. Parse the resultant stream in the response document and save it as a file on the disk.

Code to Automatically Update Fields in Word with C# REST API

This sample code demonstrates how to update Word fields in a Word file. You can update the table of contents, cross-references, page numbers, and date-time fields. When we set a destination file name, the returned document object contains a response with the same name to distinguish it from other files in the Cloud storage.

You may also check out another feature on the following page: Extract Text from Word Document with NET REST API.

 English