Updating an Index
How to Update an Index
Updating an index in ConverseCart requires a few steps, including authentication and sending the correct file format. Follow these instructions to update your index.
Obtain an API Key
First, ensure you have an API key, which is required for authentication. You can obtain this key from your account settings on the ConverseCart platform.
Prepare the Index Update File
Ensure your file is ready for upload. This file should contain the updated data for your index. Supported formats include JSON, CSV, and XML. More coming soon.
Example JSON structure:
{
[
{ "id": "1", "title": "Document 1", "content": "Content of document 1" },
{ "id": "2", "title": "Document 2", "content": "Content of document 2" }
]
}
Make a POST Request to Update the Index
Using the API key and the file, make a POST request to the index update endpoint. Include the indexID to specify which index you want to update. You can do that using cURL, python or Node.js as shown below.
- cURL
- Python
- Node.js
curl -X POST -H "API_KEY: YOUR_API_KEY" -F "indexID=YOUR_INDEX_ID" -F "file=@path_to_your_update_file" https://api.conversecart.com:8002/index/update
import requests
body = {
'indexID': 'YOUR_INDEX_ID',
'API_KEY': 'YOUR_API_KEY',
'file': open('path_to_your_update_file', 'rb')}
response = requests.post('https://api.conversecart.com:8002/index/update', body=data)
print(response.text)
const fetch = require('node-fetch');
const FormData = require('form-data');
const fs = require('fs');
const form = new FormData();
form.append('indexID', 'YOUR_INDEX_ID');
form.append('API_KEY', 'YOUR_API_KEY');
form.append('file', fs.createReadStream('path_to_your_update_file'));
fetch('https://api.conversecart.com:8002/index/update', {
method: 'POST',
body: form,
})
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Note: Always ensure your API key is kept secure and never exposed in client-side code. Verify that your update file matches the required format and structure for your index.