Add knowledge base resources
curl --request POST \
--url https://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources \
--header 'Content-Type: application/json' \
--data '
{
"resources": [
{
"type": "url",
"value": "https://acme.com/pricing",
"title": "Pricing page"
}
]
}
'import requests
url = "https://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources"
payload = { "resources": [
{
"type": "url",
"value": "https://acme.com/pricing",
"title": "Pricing page"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
resources: [{type: 'url', value: 'https://acme.com/pricing', title: 'Pricing page'}]
})
};
fetch('https://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources', 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://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'resources' => [
[
'type' => 'url',
'value' => 'https://acme.com/pricing',
'title' => 'Pricing page'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources"
payload := strings.NewReader("{\n \"resources\": [\n {\n \"type\": \"url\",\n \"value\": \"https://acme.com/pricing\",\n \"title\": \"Pricing page\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources")
.header("Content-Type", "application/json")
.body("{\n \"resources\": [\n {\n \"type\": \"url\",\n \"value\": \"https://acme.com/pricing\",\n \"title\": \"Pricing page\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"resources\": [\n {\n \"type\": \"url\",\n \"value\": \"https://acme.com/pricing\",\n \"title\": \"Pricing page\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"added": [
{
"id": "kb_res_pricing",
"type": "url",
"title": "Pricing page",
"value": "https://acme.com/pricing",
"status": "indexed"
}
],
"totalResources": 6
}
}KnowledgeBases
Add knowledge base resources
Add knowledge base resources.
POST
/
api
/
v1
/
knowledge-bases
/
{knowledgeBaseId}
/
resources
Add knowledge base resources
curl --request POST \
--url https://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources \
--header 'Content-Type: application/json' \
--data '
{
"resources": [
{
"type": "url",
"value": "https://acme.com/pricing",
"title": "Pricing page"
}
]
}
'import requests
url = "https://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources"
payload = { "resources": [
{
"type": "url",
"value": "https://acme.com/pricing",
"title": "Pricing page"
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
resources: [{type: 'url', value: 'https://acme.com/pricing', title: 'Pricing page'}]
})
};
fetch('https://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources', 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://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'resources' => [
[
'type' => 'url',
'value' => 'https://acme.com/pricing',
'title' => 'Pricing page'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$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://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources"
payload := strings.NewReader("{\n \"resources\": [\n {\n \"type\": \"url\",\n \"value\": \"https://acme.com/pricing\",\n \"title\": \"Pricing page\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources")
.header("Content-Type", "application/json")
.body("{\n \"resources\": [\n {\n \"type\": \"url\",\n \"value\": \"https://acme.com/pricing\",\n \"title\": \"Pricing page\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://optareach.com/api/v1/knowledge-bases/{knowledgeBaseId}/resources")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"resources\": [\n {\n \"type\": \"url\",\n \"value\": \"https://acme.com/pricing\",\n \"title\": \"Pricing page\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"added": [
{
"id": "kb_res_pricing",
"type": "url",
"title": "Pricing page",
"value": "https://acme.com/pricing",
"status": "indexed"
}
],
"totalResources": 6
}
}