from ai21 import AI21Client
client = AI21Client()
file_id = client.library.files.create(
labels=["label1", "label2"],
public_url="www.example.com",
)
uploaded_file = client.library.files.get(file_id)
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: '{"publicUrl":"<string>","labels":["<string>"]}'
};
fetch('https://api.ai21.com/studio/v1/library/files/{file_id}', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files/{file_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "{\n \"publicUrl\": \"<string>\",\n \"labels\": [\n \"<string>\"\n ]\n}",
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/ioutil"
)
func main() {
url := "https://api.ai21.com/studio/v1/library/files/{file_id}"
payload := strings.NewReader("{\n \"publicUrl\": \"<string>\",\n \"labels\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
curl --request PUT \
--url https://api.ai21.com/studio/v1/library/files/{file_id} \
--header 'Content-Type: application/json' \
--data '{
"publicUrl": "<string>",
"labels": [
"<string>"
]
}'
HttpResponse<String> response = Unirest.put("https://api.ai21.com/studio/v1/library/files/{file_id}")
.header("Content-Type", "application/json")
.body("{\n \"publicUrl\": \"<string>\",\n \"labels\": [\n \"<string>\"\n ]\n}")
.asString();
File Library Management
Update file
Update the specified parameters of a specific document in the user’s library. This operation currently supports updating the publicUrl and labels parameters.
PUT
/
studio
/
v1
/
library
/
files
/
{file_id}
from ai21 import AI21Client
client = AI21Client()
file_id = client.library.files.create(
labels=["label1", "label2"],
public_url="www.example.com",
)
uploaded_file = client.library.files.get(file_id)
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: '{"publicUrl":"<string>","labels":["<string>"]}'
};
fetch('https://api.ai21.com/studio/v1/library/files/{file_id}', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files/{file_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "{\n \"publicUrl\": \"<string>\",\n \"labels\": [\n \"<string>\"\n ]\n}",
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/ioutil"
)
func main() {
url := "https://api.ai21.com/studio/v1/library/files/{file_id}"
payload := strings.NewReader("{\n \"publicUrl\": \"<string>\",\n \"labels\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
curl --request PUT \
--url https://api.ai21.com/studio/v1/library/files/{file_id} \
--header 'Content-Type: application/json' \
--data '{
"publicUrl": "<string>",
"labels": [
"<string>"
]
}'
HttpResponse<String> response = Unirest.put("https://api.ai21.com/studio/v1/library/files/{file_id}")
.header("Content-Type", "application/json")
.body("{\n \"publicUrl\": \"<string>\",\n \"labels\": [\n \"<string>\"\n ]\n}")
.asString();
Request body
Responses
If the update is successful, the server will return an HTTP status code 200 with no body content. If the document ID does not exist, a 422 error message will be returned.from ai21 import AI21Client
client = AI21Client()
file_id = client.library.files.create(
labels=["label1", "label2"],
public_url="www.example.com",
)
uploaded_file = client.library.files.get(file_id)
const options = {
method: 'PUT',
headers: {'Content-Type': 'application/json'},
body: '{"publicUrl":"<string>","labels":["<string>"]}'
};
fetch('https://api.ai21.com/studio/v1/library/files/{file_id}', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.ai21.com/studio/v1/library/files/{file_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "{\n \"publicUrl\": \"<string>\",\n \"labels\": [\n \"<string>\"\n ]\n}",
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/ioutil"
)
func main() {
url := "https://api.ai21.com/studio/v1/library/files/{file_id}"
payload := strings.NewReader("{\n \"publicUrl\": \"<string>\",\n \"labels\": [\n \"<string>\"\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
curl --request PUT \
--url https://api.ai21.com/studio/v1/library/files/{file_id} \
--header 'Content-Type: application/json' \
--data '{
"publicUrl": "<string>",
"labels": [
"<string>"
]
}'
HttpResponse<String> response = Unirest.put("https://api.ai21.com/studio/v1/library/files/{file_id}")
.header("Content-Type", "application/json")
.body("{\n \"publicUrl\": \"<string>\",\n \"labels\": [\n \"<string>\"\n ]\n}")
.asString();
Was this page helpful?

