logoBack to home screen

Searching and Replacing in HTML and DOCX Files with REST

ADx enables you to search and replace strings in HTML and DOCX files. You can send one one the following requests:

  • /access.adx.content.{your-repository-name}/v1/convert/search-replace/by-single-search (Search And Replace By Id Single Search) Enables you to search and replace text within one content. See Search and Replace in One Content
  • /access.adx.content.{your-repository-name}/v1/convert/search-replace (Search And Replace By Id) Enables you to search and replace text across multiple contents by specifying content IDs inside a JSON body. See Search and Replace within Multiple Contents

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 true, the search is case sensitive.
regularExpressionIf true, the search string is treated as a regular expression.
replaceThe string that replaces the found words.
wholeWordIf true, the whole word gets replaced.

Search and Replace within Multiple Contents

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

  • Regular expression or string to be found and replaced.
  • Match Case flag
  • 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\"}"