Skip to main content
Version: 2.8

Searching and replacing text in HTML and DOCX files via REST

Document.One (D1) enables you to search and replace text strings in HTML and DOCX files. You can send one of the following requests:

HTTP requestEndpointService description
POST/access.adx.content.{your-repository-name}/v1/convert/search-replace/by-single-searchSearch and replace by ID single search. Enables you to search and replace text within one content. See Task 1: Search and replace in one content.
POST/access.adx.content.{your-repository-name}/v1/convert/search-replaceSearch and replace by ID. Enables you to search and replace text across multiple contents by specifying content IDs inside a JSON body. See Task 2: Search and replace within multiple contents.

Task 1: Search and replace in one content

You have to specify the following parameters:

ParameterDescription
contentIdThe technical ID of the content where you want to search and replace words.
searchThe string to search for.
matchCaseIf set to true, the search is case sensitive.
regularExpressionIf set to true, the search string is treated as a regular expression.
replaceThe string that replaces the found words.
wholeWordIf set to true, the whole word gets replaced.

Task 2: Search and replace within multiple contents

Send this request to process multiple contents at once. For each content, you must provide searchAndReplaceSpecifications that defines:

  • the regular expression or string to be found and replaced,
  • the match case flag,
  • the whole word flag,
  • if the result action is NEW_CONTENT, you must provide newContentSpecification.

The following JSON sample replaces MyFile with YourFile in a single content.


{"contentId":"4961adec-7369-4ff6-80b5-759c3c362647",
"searchAndReplaceSpecifications":
[
{
"stringReplacementMatchCase":true,
"stringReplacementMatchWholeWord":true,
"stringReplacements":
{
"MyFile":"YourFile"
}
}
],
"resultAction":"CONTENT_REPRESENTATION"
}

The cURL request is then:

curl -X POST "https://dev-phoenix-adx.staging.tribefire.cloud/services/api/v1/access.adx.content.default/v1/convert/search-replace" -H  "accept: application/json" -H  "Content-Type: application/json" -d "{\"contentId\":\"4961adec-7369-4ff6-80b5-759c3c362647\",\"searchAndReplaceSpecifications\":[{\"stringReplacementMatchCase\":true,\"stringReplacementMatchWholeWord\":true,\"stringReplacements\":{\"MyFile\":\"YourFile\"}}],\"resultAction\":\"CONTENT_REPRESENTATION\"}"

OpenAPI

For code samples, see

Search and replace by ID
Search and replace by ID single search