curl --request POST \
--url https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file_data_source_name=@example-file \
--form 'text_data_source_name=Text content'import requests
url = "https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources"
files = { "file_data_source_name": ("example-file", open("example-file", "rb")) }
payload = { "text_data_source_name": "Text content" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file_data_source_name', '<string>');
form.append('text_data_source_name', 'Text content');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_data_source_name\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text_data_source_name\"\r\n\r\nText content\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_data_source_name\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text_data_source_name\"\r\n\r\nText content\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_data_source_name\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text_data_source_name\"\r\n\r\nText content\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_data_source_name\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text_data_source_name\"\r\n\r\nText content\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"q1": [
{
"id": 330783,
"type": "text",
"name": "sample.txt",
"status": "in-progress",
"errors": null
},
{
"id": 330784,
"type": "text",
"name": "sample2.txt",
"status": "in-progress",
"errors": null
},
{
"id": 330785,
"type": "file",
"name": "File.pdf",
"status": "in-progress",
"errors": null
}
],
"d2": [
{
"id": 330786,
"type": "file",
"name": "File2.pdf",
"status": "in-progress",
"errors": null
}
],
"knowledge_base_id": 876,
"ok": true
}Add text/file data sources
Uploads files or text to an existing knowledge base as data sources. Send them as multipart form data.
curl --request POST \
--url https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form file_data_source_name=@example-file \
--form 'text_data_source_name=Text content'import requests
url = "https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources"
files = { "file_data_source_name": ("example-file", open("example-file", "rb")) }
payload = { "text_data_source_name": "Text content" }
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file_data_source_name', '<string>');
form.append('text_data_source_name', 'Text content');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_data_source_name\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text_data_source_name\"\r\n\r\nText content\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_data_source_name\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text_data_source_name\"\r\n\r\nText content\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources")
.header("Authorization", "Bearer <token>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_data_source_name\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text_data_source_name\"\r\n\r\nText content\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.wotnot.io/api/v1/ai/knowledge-base/{knowledge_base_id}/upload/sources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_data_source_name\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"text_data_source_name\"\r\n\r\nText content\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"q1": [
{
"id": 330783,
"type": "text",
"name": "sample.txt",
"status": "in-progress",
"errors": null
},
{
"id": 330784,
"type": "text",
"name": "sample2.txt",
"status": "in-progress",
"errors": null
},
{
"id": 330785,
"type": "file",
"name": "File.pdf",
"status": "in-progress",
"errors": null
}
],
"d2": [
{
"id": 330786,
"type": "file",
"name": "File2.pdf",
"status": "in-progress",
"errors": null
}
],
"knowledge_base_id": 876,
"ok": true
}Authorizations
All of WotNot's APIs use Bearer token authentication. Send your account token as Bearer <token>. You can find it in Settings > Account Settings > Developer. Keep it on your server: anyone who has it can call the API as your account.
Path Parameters
The ID of the knowledge base to add the data sources to.
Body
Send files and text as multipart form data. Give each form field a unique key, and put either a file or text in it.
A form field that holds a file. Its value is the location of the file to upload. Give each form field its own unique key.
A form field that holds text. Its value is the text content to add. Give each form field its own unique key.
"Text content"
Add more form fields the same way, each with its own unique key. Each one holds either a file or text.
Response
Returns ok set to true, the knowledge base's ID, and the new data sources grouped by the form field they came from (q1 and d2 in the example). Each one starts with status set to in-progress.
Was this page helpful?