Endpoint Name: update_document
Request type : POST
Authorization: Bearer token as header
Endpoint Details: The update_documentendpoint
will be used to update the document.
URL/access/klearstack/update_document
Request Body
Name of the company for which the user is logging in
Name of collection of document
A valid JSON string containing details of updates to be done to fields of Document.
If coordinates are not available then array will [0,0,0,0]
Example :
{
"doc_date_value": {
"_value": "02-Oct-2022",
"_coordinates": [1306,87,1444,107],
},
"doc_number_value": {
"_value": "287269549621X10102022",
"_coordinates": [1306,87,1444,107],
},
}
Shell (cURL)
curl -X POST "URL/access/klearstack/update_document" \
-H "Authorization: Bearer your_token_here" \
-H "Content-Type: application/json" \
-d '{
"company_name": "Replace_Company_Name_Here",
"collection_name": "Replace_Collection_Name_Here",
"id": "Replace_Document_ID_Here",
"data": {
"doc_date_value": {
"_value": "02-Oct-2022",
"_coordinates": [1306, 87, 1444, 107]
},
"doc_number_value": {
"_value": "287269549621X10102022",
"_coordinates": [1306, 87, 1444, 107]
}
}
}'
Python
import requests
# API URL
url = "URL/access/klearstack/update_document"
# Request payload
data = {
"company_name": "Replace_Company_Name_Here",
"collection_name": "Replace_Collection_Name_Here",
"id": "Replace_Document_ID_Here",
"data": {
"doc_date_value": {
"_value": "02-Oct-2022",
"_coordinates": [1306, 87, 1444, 107]
},
"doc_number_value": {
"_value": "287269549621X10102022",
"_coordinates": [1306, 87, 1444, 107]
}
}
}
# Headers
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer your_token_here"
}
# Make the POST request
response = requests.post(url, json=data, headers=headers)
# Print the response
if response.status_code == 200:
print(response.json())
else:
print("Error:", response.text)
Java
import okhttp3.*;
import java.io.IOException;
public class UpdateDocumentAPI {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient();
// JSON payload
String jsonPayload = "{ \"company_name\": \"Replace_Company_Name_Here\", " +
"\"collection_name\": \"Replace_Collection_Name_Here\", " +
"\"id\": \"Replace_Document_ID_Here\", " +
"\"data\": { " +
" \"doc_date_value\": { \"_value\": \"02-Oct-2022\", \"_coordinates\": [1306, 87, 1444, 107] }, " +
" \"doc_number_value\": { \"_value\": \"287269549621X10102022\", \"_coordinates\": [1306, 87, 1444, 107] } " +
"}}";
RequestBody body = RequestBody.create(
jsonPayload, MediaType.parse("application/json"));
Request request = new Request.Builder()
.url("URL/access/klearstack/update_document")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer your_token_here")
.build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
System.out.println("Response: " + response.body().string());
} else {
System.out.println("Error: " + response.body().string());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Node.js
var request = require('request');
const form_data = {
'company_name': 'Replace_Company_Name_Here',
'collection_name': 'Replace_Collection_Name_Here',
'id': 'Replace_Document_ID_Here',
'data': {
'doc_date_value': {
'_value': '02-Oct-2022',
'_coordinates': [1306, 87, 1444, 107]
},
'doc_number_value': {
'_value': '287269549621X10102022',
'_coordinates': [1306, 87, 1444, 107]
}
}
};
const options = {
url: 'URL/access/klearstack/update_document',
json: form_data,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your_token_here'
}
};
request.post(options, function(err, httpResponse, body) {
if (err) {
console.error('Request failed:', err);
return;
}
console.log('Response:', body);
});
JavaScript (Vanilla)
var payload = JSON.stringify({
company_name: "Replace_Company_Name_Here",
collection_name: "Replace_Collection_Name_Here",
id: "Replace_Document_ID_Here",
data: {
doc_date_value: {
_value: "02-Oct-2022",
_coordinates: [1306, 87, 1444, 107]
},
doc_number_value: {
_value: "287269549621X10102022",
_coordinates: [1306, 87, 1444, 107]
}
}
});
var xhr = new XMLHttpRequest();
xhr.open("POST", "URL/access/klearstack/update_document", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer your_token_here");
// Handle response
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
console.log("Response:", xhr.responseText);
} else {
console.error("Error:", xhr.responseText);
}
}
};
// Send request
xhr.send(payload);
API Response