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 request | Endpoint | Service description |
---|---|---|
POST | /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 Task 1: Search and replace in one content. |
POST | /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 Task 2: Search and replace within multiple contents. |
Task 1: Search and replace in one content
You have to specify the following parameters:
Parameter | Description |
---|---|
contentId | The technical ID of the content where you want to search and replace words. |
search | The string to search for. |
matchCase | If set to true , the search is case sensitive. |
regularExpression | If set to true , the search string is treated as a regular expression. |
replace | The string that replaces the found words. |
wholeWord | If 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 providenewContentSpecification
.
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