curl --request POST \
--url https://api.stackone.com/unified/documents/files/upload \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'x-account-id: <x-account-id>' \
--data '
{
"name": "weather-forecast",
"file_format": {
"value": "pdf",
"source_value": "application/pdf"
},
"content": "VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE",
"category_id": "6530",
"path": "/path/to/file",
"category": {
"value": "reports, resumes",
"source_value": "550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME"
},
"confidential": {
"value": "true",
"source_value": "public"
}
}
'import requests
url = "https://api.stackone.com/unified/documents/files/upload"
payload = {
"name": "weather-forecast",
"file_format": {
"value": "pdf",
"source_value": "application/pdf"
},
"content": "VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE",
"category_id": "6530",
"path": "/path/to/file",
"category": {
"value": "reports, resumes",
"source_value": "550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME"
},
"confidential": {
"value": "true",
"source_value": "public"
}
}
headers = {
"x-account-id": "<x-account-id>",
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-account-id': '<x-account-id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'weather-forecast',
file_format: {value: 'pdf', source_value: 'application/pdf'},
content: 'VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE',
category_id: '6530',
path: '/path/to/file',
category: {
value: 'reports, resumes',
source_value: '550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME'
},
confidential: {value: 'true', source_value: 'public'}
})
};
fetch('https://api.stackone.com/unified/documents/files/upload', 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.stackone.com/unified/documents/files/upload",
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([
'name' => 'weather-forecast',
'file_format' => [
'value' => 'pdf',
'source_value' => 'application/pdf'
],
'content' => 'VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE',
'category_id' => '6530',
'path' => '/path/to/file',
'category' => [
'value' => 'reports, resumes',
'source_value' => '550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME'
],
'confidential' => [
'value' => 'true',
'source_value' => 'public'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"x-account-id: <x-account-id>"
],
]);
$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.stackone.com/unified/documents/files/upload"
payload := strings.NewReader("{\n \"name\": \"weather-forecast\",\n \"file_format\": {\n \"value\": \"pdf\",\n \"source_value\": \"application/pdf\"\n },\n \"content\": \"VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE\",\n \"category_id\": \"6530\",\n \"path\": \"/path/to/file\",\n \"category\": {\n \"value\": \"reports, resumes\",\n \"source_value\": \"550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME\"\n },\n \"confidential\": {\n \"value\": \"true\",\n \"source_value\": \"public\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-account-id", "<x-account-id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
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://api.stackone.com/unified/documents/files/upload")
.header("x-account-id", "<x-account-id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"weather-forecast\",\n \"file_format\": {\n \"value\": \"pdf\",\n \"source_value\": \"application/pdf\"\n },\n \"content\": \"VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE\",\n \"category_id\": \"6530\",\n \"path\": \"/path/to/file\",\n \"category\": {\n \"value\": \"reports, resumes\",\n \"source_value\": \"550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME\"\n },\n \"confidential\": {\n \"value\": \"true\",\n \"source_value\": \"public\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.stackone.com/unified/documents/files/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-account-id"] = '<x-account-id>'
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"weather-forecast\",\n \"file_format\": {\n \"value\": \"pdf\",\n \"source_value\": \"application/pdf\"\n },\n \"content\": \"VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE\",\n \"category_id\": \"6530\",\n \"path\": \"/path/to/file\",\n \"category\": {\n \"value\": \"reports, resumes\",\n \"source_value\": \"550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME\"\n },\n \"confidential\": {\n \"value\": \"true\",\n \"source_value\": \"public\"\n }\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 201,
"message": "Employee created successfully",
"timestamp": "2021-01-01T01:01:01.000Z",
"provider_errors": [
{
"status": 400,
"url": "https://api.someprovider.com/v1/endpoint",
"raw": {
"error": "Bad Request",
"message": "The supplied data is invalid"
},
"headers": {
"date": "Tue, 02 Apr 2024 13:52:01 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "close"
}
}
],
"unified_warnings": [
{
"message": "The provided field type is not supported in the current model."
}
]
}{
"statusCode": 400,
"message": "Bad Request",
"timestamp": "2023-05-30T00:00:00.000Z",
"data": {
"statusCode": 400,
"message": "Bad Request",
"headers": {
"content-type": "application/json",
"x-request-id": "5678c28b211dace4e0a0f9171e6b88c5"
}
},
"provider_errors": [
{
"status": 400,
"url": "https://api.provider.com/v1/resource",
"raw": {
"message": "Invalid input parameters"
},
"headers": {
"content-type": "application/json",
"x-request-id": "5678c28b211dace4e0a0f9171e6b88c5"
}
}
]
}{
"statusCode": 401,
"message": "Unauthorized",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 403,
"message": "Forbidden resource",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 404,
"message": "Not Found",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 408,
"message": "Request timed out",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 409,
"message": "Conflict",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 412,
"message": "Precondition failed",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 422,
"message": "Unprocessable Entity",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 429,
"message": "Too many requests",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 500,
"message": "Internal server error",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 501,
"message": "Not Implemented",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 502,
"message": "Bad Gateway",
"timestamp": "2023-05-30T00:00:00.000Z"
}Upload File
curl --request POST \
--url https://api.stackone.com/unified/documents/files/upload \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--header 'x-account-id: <x-account-id>' \
--data '
{
"name": "weather-forecast",
"file_format": {
"value": "pdf",
"source_value": "application/pdf"
},
"content": "VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE",
"category_id": "6530",
"path": "/path/to/file",
"category": {
"value": "reports, resumes",
"source_value": "550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME"
},
"confidential": {
"value": "true",
"source_value": "public"
}
}
'import requests
url = "https://api.stackone.com/unified/documents/files/upload"
payload = {
"name": "weather-forecast",
"file_format": {
"value": "pdf",
"source_value": "application/pdf"
},
"content": "VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE",
"category_id": "6530",
"path": "/path/to/file",
"category": {
"value": "reports, resumes",
"source_value": "550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME"
},
"confidential": {
"value": "true",
"source_value": "public"
}
}
headers = {
"x-account-id": "<x-account-id>",
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'x-account-id': '<x-account-id>',
Authorization: 'Basic <encoded-value>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'weather-forecast',
file_format: {value: 'pdf', source_value: 'application/pdf'},
content: 'VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE',
category_id: '6530',
path: '/path/to/file',
category: {
value: 'reports, resumes',
source_value: '550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME'
},
confidential: {value: 'true', source_value: 'public'}
})
};
fetch('https://api.stackone.com/unified/documents/files/upload', 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.stackone.com/unified/documents/files/upload",
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([
'name' => 'weather-forecast',
'file_format' => [
'value' => 'pdf',
'source_value' => 'application/pdf'
],
'content' => 'VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE',
'category_id' => '6530',
'path' => '/path/to/file',
'category' => [
'value' => 'reports, resumes',
'source_value' => '550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME'
],
'confidential' => [
'value' => 'true',
'source_value' => 'public'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json",
"x-account-id: <x-account-id>"
],
]);
$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.stackone.com/unified/documents/files/upload"
payload := strings.NewReader("{\n \"name\": \"weather-forecast\",\n \"file_format\": {\n \"value\": \"pdf\",\n \"source_value\": \"application/pdf\"\n },\n \"content\": \"VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE\",\n \"category_id\": \"6530\",\n \"path\": \"/path/to/file\",\n \"category\": {\n \"value\": \"reports, resumes\",\n \"source_value\": \"550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME\"\n },\n \"confidential\": {\n \"value\": \"true\",\n \"source_value\": \"public\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-account-id", "<x-account-id>")
req.Header.Add("Authorization", "Basic <encoded-value>")
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://api.stackone.com/unified/documents/files/upload")
.header("x-account-id", "<x-account-id>")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"weather-forecast\",\n \"file_format\": {\n \"value\": \"pdf\",\n \"source_value\": \"application/pdf\"\n },\n \"content\": \"VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE\",\n \"category_id\": \"6530\",\n \"path\": \"/path/to/file\",\n \"category\": {\n \"value\": \"reports, resumes\",\n \"source_value\": \"550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME\"\n },\n \"confidential\": {\n \"value\": \"true\",\n \"source_value\": \"public\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.stackone.com/unified/documents/files/upload")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-account-id"] = '<x-account-id>'
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"weather-forecast\",\n \"file_format\": {\n \"value\": \"pdf\",\n \"source_value\": \"application/pdf\"\n },\n \"content\": \"VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE\",\n \"category_id\": \"6530\",\n \"path\": \"/path/to/file\",\n \"category\": {\n \"value\": \"reports, resumes\",\n \"source_value\": \"550e8400-e29b-41d4-a716-446655440000, CUSTOM_CATEGORY_NAME\"\n },\n \"confidential\": {\n \"value\": \"true\",\n \"source_value\": \"public\"\n }\n}"
response = http.request(request)
puts response.read_body{
"statusCode": 201,
"message": "Employee created successfully",
"timestamp": "2021-01-01T01:01:01.000Z",
"provider_errors": [
{
"status": 400,
"url": "https://api.someprovider.com/v1/endpoint",
"raw": {
"error": "Bad Request",
"message": "The supplied data is invalid"
},
"headers": {
"date": "Tue, 02 Apr 2024 13:52:01 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "close"
}
}
],
"unified_warnings": [
{
"message": "The provided field type is not supported in the current model."
}
]
}{
"statusCode": 400,
"message": "Bad Request",
"timestamp": "2023-05-30T00:00:00.000Z",
"data": {
"statusCode": 400,
"message": "Bad Request",
"headers": {
"content-type": "application/json",
"x-request-id": "5678c28b211dace4e0a0f9171e6b88c5"
}
},
"provider_errors": [
{
"status": 400,
"url": "https://api.provider.com/v1/resource",
"raw": {
"message": "Invalid input parameters"
},
"headers": {
"content-type": "application/json",
"x-request-id": "5678c28b211dace4e0a0f9171e6b88c5"
}
}
]
}{
"statusCode": 401,
"message": "Unauthorized",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 403,
"message": "Forbidden resource",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 404,
"message": "Not Found",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 408,
"message": "Request timed out",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 409,
"message": "Conflict",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 412,
"message": "Precondition failed",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 422,
"message": "Unprocessable Entity",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 429,
"message": "Too many requests",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 500,
"message": "Internal server error",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 501,
"message": "Not Implemented",
"timestamp": "2023-05-30T00:00:00.000Z"
}{
"statusCode": 502,
"message": "Bad Gateway",
"timestamp": "2023-05-30T00:00:00.000Z"
}Authorizations
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Headers
The account identifier
The session token
Body
The filename of the file to upload
"weather-forecast"
The file format of the file
Show child attributes
Show child attributes
The base64 encoded content of the file to upload
"VGhpcyBpc24ndCByZWFsbHkgYSBzYW1wbGUgZmlsZSwgYnV0IG5vIG9uZSB3aWxsIGV2ZXIga25vdyE"
The categoryId of the documents
"6530"
The path for the file to be uploaded to
"/path/to/file"
The category object for associating uploaded files. If both an ID and a name are provided, the ID takes precedence.
Show child attributes
Show child attributes
The confidentiality level of the file to be uploaded
Show child attributes
Show child attributes
Response
The file was uploaded.
201
"Employee created successfully"
"2021-01-01T01:01:01.000Z"
Show child attributes
Show child attributes
[
{
"status": 400,
"url": "https://api.someprovider.com/v1/endpoint",
"raw": {
"error": "Bad Request",
"message": "The supplied data is invalid"
},
"headers": {
"date": "Tue, 02 Apr 2024 13:52:01 GMT",
"content-type": "application/json; charset=utf-8",
"transfer-encoding": "chunked",
"connection": "close"
}
}
]
Show child attributes
Show child attributes
[
{
"message": "The provided field type is not supported in the current model."
}
]
Was this page helpful?