POST /v1/processing/review/removetrackedchange
POST https://api.reporting.cloud/v1/processing/review/removetrackedchange
Description
Accepts or rejects one tracked change of a document and returns the changed document. The request body is the document as a Base64 string; id names the change, as POST /v1/processing/review/trackedchanges numbers it, and accept accepts (true) or rejects (false) it. The response holds the document, always in the TX format, and whether the change was removed. Removing a change renumbers the ones after it, so read the ids again before you remove another one. See Tracked Changes.
Warning
Document Quota. Each successful request counts 1 against the document quota. It counts 1 also when nothing is removed, because the document has no change with that id. Plans and Licensing lists the quota of each plan.
Examples
Request:
curl username:password \
"Content-Type: application/json" \
"\"CAcBAA4AAAAAAAAAAAAAAAIAAABsAQAAAQ...==\"" \
POST "https://api.reporting.cloud/v1/processing/review/removetrackedchange?id=1&accept=true"
Results:
{"document":"CAcBAA4AAAAAAAAAAAAAAAIAAABsAQAAAQ...==","removed":true}
Request:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using TXTextControl.ReportingCloud;
class RCSamples
{
public static void RemoveTrackedChange(string documentName)
{
ReportingCloud rc = new ReportingCloud(
"username",
"password",
new Uri("https://api.reporting.cloud"));
try
{
// Accept the tracked change with the id 1
byte[] bDocument = File.ReadAllBytes(documentName);
TrackedChangeModifiedDocument modifiedDocument =
rc.Processing.Review.RemoveTrackedChange(bDocument, 1, true);
File.WriteAllBytes("tracked_changes_accepted.tx", modifiedDocument.Document);
Console.WriteLine("Tracked change removed: " + modifiedDocument.Removed);
}
catch (Exception e)
{
Console.WriteLine("An error occurred: " + e.Message);
}
}
}
Results:
Tracked change removed: True
If the document has no change with the given id, the response's document is null, and RemoveTrackedChange throws an ArgumentNullException instead of returning a Removed of false: the sample then prints "An error occurred: …", never "Tracked change removed: False".
// Example code coming soon.
# Example code coming soon.
Request:
require_once __DIR__ . '/vendor/autoload.php';
use TextControl\ReportingCloud\ReportingCloud;
$reportingCloud = new ReportingCloud([
'api_key' => (string) getenv('REPORTINGCLOUD_API_KEY'),
]);
$sourceFilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tracked_changes.docx';
$destinationFilename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tracked_changes_accepted.tx';
$result = $reportingCloud->removeTrackedChange($sourceFilename, 1, true);
file_put_contents($destinationFilename, $result['document']);
var_dump($result['removed']);
Results:
bool(true)
Authorization
This endpoint requires a "ReportingCloud-APIKey" or a "Basic" user authorization to access the user account, data and templates. Only one of these two methods is required.
API Keys describes how to create an API key, and Authentication explains both header forms.
ReportingCloud-APIKey
| Header field | Description |
|---|---|
| Authorization | Required. A valid ReportingCloud account is required. The Authorization field is constructed as follows: An API key needs to be generated in the portal or with PUT /v1/account/apikey. The authorization method and a space, "ReportingCloud-APIKey ", is then put before the actual API key string. For example: Authorization: ReportingCloud-APIKey oMDM4MrAqL9QEOpyzupnQW5NjvCNtvE5cVDaaLqxI |
Basic
| Header field | Description |
|---|---|
| Authorization | Required. A valid ReportingCloud account is required. The Authorization field is constructed as follows: The user name and password are combined into a string separated by a colon, for example username:password. The resulting string is encoded using the RFC2045-MIME variant of Base64, except not limited to 76 char/line. The authorization method and a space, "Basic ", is then put before the encoded string. For example: Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l |
Request Parameters
| Name | Type | Value | Optional |
|---|---|---|---|
| id | Integer | The id of the tracked change that needs to be removed. This id can be obtained using the /v1/processing/review/trackedchanges endpoint. After a removal, the ids of the changes that follow the removed one decrease by 1: list the changes of the returned document again before removing the next one. | no |
| accept | Boolean | Specifies whether the tracked change should be accepted or not (reject): true or false. | no |
Request Payload
| Type | Value |
|---|---|
| Base64 encoded string | The source document encoded as a Base64 string. Possible document formats are .rtf, .doc, .docx and .tx. A document in another format isn't refused: the response says that no change was removed. |
Success Response
| Status | Description |
|---|---|
| 200 | On success, the HTTP status code in the response header is 200 (OK). The response body contains a ModifiedDocument object. |
ModifiedDocument
| Name | Type | Value | Optional |
|---|---|---|---|
| document | String | The modified document encoded as a Base64 string in the internal TX Text Control format (TX), whatever the format of the source document. null, if no change was removed. | no |
| removed | Boolean | Specifies whether the specified tracked change has been removed or not. false, if the document has no change with the given id. | no |
Error Response
| Status | Description |
|---|---|
| 400 | A 400 (Bad Request) with the JSON body {"Message":"The request is invalid."} is returned, if id is not an integer, accept is not true or false, or either is given without a value. |
| 403 | A 403 (Forbidden) is returned, if the user is not authorized or the document quota is exceeded. |
| 404 | A 404 (Not Found) is returned, if a required query parameter is missing. |
| 405 | A 405 (Method Not Allowed) is returned, if the request uses another HTTP method than POST. The Allow header of the response names POST. |
| 411 | A 411 (Length Required) is returned, if the request has neither a body nor a Content-Length header. |
| 415 | A 415 (Unsupported Media Type) is returned, if the request has a body but no Content-Type header, or a Content-Type such as text/plain that the endpoint doesn't read. Send Content-Type: application/json. |
| 500 | A 500 (Internal Server Error) is returned, if the request has no Authorization header, an empty one or one that is not the authorization method, a space and the credentials, or if the request body is empty or is not a JSON string of valid Base64 data. |