Uploads a file and returns a link to it.
Send it as multipart/form-data with the file part named file, plus
itemType (Ticket, Task, Project or Document) and itemId.
The record has to exist and be yours - an upload against an unknown id is a 404 rather than an orphaned file nothing will ever reference.
The returned url carries a time-limited access token. Pass the name and url together to a comment endpoint to attach the file; the token is stripped before storage and a fresh one issued on every read, so do not store the url yourself.
The largest accepted upload is 44 MB, and 25 MB for a document. A document’s files are
attached by sending the name and url in Attachments on
PATCH /v1/documents/{documentId}.
curl --request POST \
--url https://api.usw.gorelo.io/v1/attachments \
--header 'Content-Type: multipart/form-data' \
--header 'X-API-Key: <api-key>' \
--form file=@example-file \
--form 'itemType=<string>' \
--form itemId=3c90c3cc-0d44-4b50-8888-8dd25736052aimport requests
url = "https://api.usw.gorelo.io/v1/attachments"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"itemType": "<string>",
"itemId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('itemType', '<string>');
form.append('itemId', '3c90c3cc-0d44-4b50-8888-8dd25736052a');
const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
options.body = form;
fetch('https://api.usw.gorelo.io/v1/attachments', 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.usw.gorelo.io/v1/attachments",
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\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemType\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemId\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"X-API-Key: <api-key>"
],
]);
$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.usw.gorelo.io/v1/attachments"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemType\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemId\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.usw.gorelo.io/v1/attachments")
.header("X-API-Key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemType\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemId\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usw.gorelo.io/v1/attachments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemType\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemId\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"StatusCode": 100,
"IsSuccess": true,
"Data": {
"Name": "<string>",
"Url": "<string>"
},
"DataContext": null,
"Notifications": [
{
"Code": "070101",
"Message": "<string>",
"PropertyName": "<string>",
"ActionHint": "<string>",
"DocUrl": "<string>"
}
]
}{
"StatusCode": 100,
"IsSuccess": true,
"Data": null,
"DataContext": {
"TraceId": "<string>"
},
"Notifications": [
{
"Code": "070101",
"Message": "<string>",
"PropertyName": "<string>",
"ActionHint": "<string>",
"DocUrl": "<string>"
}
]
}{
"StatusCode": 100,
"IsSuccess": true,
"Data": null,
"DataContext": {
"TraceId": "<string>"
},
"Notifications": [
{
"Code": "070101",
"Message": "<string>",
"PropertyName": "<string>",
"ActionHint": "<string>",
"DocUrl": "<string>"
}
]
}{
"StatusCode": 100,
"IsSuccess": true,
"Data": null,
"DataContext": {
"TraceId": "<string>"
},
"Notifications": [
{
"Code": "070101",
"Message": "<string>",
"PropertyName": "<string>",
"ActionHint": "<string>",
"DocUrl": "<string>"
}
]
}{
"StatusCode": 100,
"IsSuccess": true,
"Data": null,
"DataContext": {
"TraceId": "<string>"
},
"Notifications": [
{
"Code": "070101",
"Message": "<string>",
"PropertyName": "<string>",
"ActionHint": "<string>",
"DocUrl": "<string>"
}
]
}Autoritzacions
Your Gorelo API key. See Generate API key. If your data is hosted in Australia, click the base URL at the top of this page and select https://api.aue.gorelo.io.
Resposta
OK
100, 101, 102, 103, 200, 201, 202, 203, 204, 205, 206, 207, 208, 226, 300, 301, 302, 303, 304, 305, 306, 307, 308, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 421, 422, 423, 424, 426, 428, 429, 431, 451, 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511 Aquesta pàgina us ha estat útil?
curl --request POST \
--url https://api.usw.gorelo.io/v1/attachments \
--header 'Content-Type: multipart/form-data' \
--header 'X-API-Key: <api-key>' \
--form file=@example-file \
--form 'itemType=<string>' \
--form itemId=3c90c3cc-0d44-4b50-8888-8dd25736052aimport requests
url = "https://api.usw.gorelo.io/v1/attachments"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"itemType": "<string>",
"itemId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('file', '<string>');
form.append('itemType', '<string>');
form.append('itemId', '3c90c3cc-0d44-4b50-8888-8dd25736052a');
const options = {method: 'POST', headers: {'X-API-Key': '<api-key>'}};
options.body = form;
fetch('https://api.usw.gorelo.io/v1/attachments', 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.usw.gorelo.io/v1/attachments",
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\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemType\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemId\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data",
"X-API-Key: <api-key>"
],
]);
$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.usw.gorelo.io/v1/attachments"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemType\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemId\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.usw.gorelo.io/v1/attachments")
.header("X-API-Key", "<api-key>")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemType\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemId\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.usw.gorelo.io/v1/attachments")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemType\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"itemId\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"StatusCode": 100,
"IsSuccess": true,
"Data": {
"Name": "<string>",
"Url": "<string>"
},
"DataContext": null,
"Notifications": [
{
"Code": "070101",
"Message": "<string>",
"PropertyName": "<string>",
"ActionHint": "<string>",
"DocUrl": "<string>"
}
]
}{
"StatusCode": 100,
"IsSuccess": true,
"Data": null,
"DataContext": {
"TraceId": "<string>"
},
"Notifications": [
{
"Code": "070101",
"Message": "<string>",
"PropertyName": "<string>",
"ActionHint": "<string>",
"DocUrl": "<string>"
}
]
}{
"StatusCode": 100,
"IsSuccess": true,
"Data": null,
"DataContext": {
"TraceId": "<string>"
},
"Notifications": [
{
"Code": "070101",
"Message": "<string>",
"PropertyName": "<string>",
"ActionHint": "<string>",
"DocUrl": "<string>"
}
]
}{
"StatusCode": 100,
"IsSuccess": true,
"Data": null,
"DataContext": {
"TraceId": "<string>"
},
"Notifications": [
{
"Code": "070101",
"Message": "<string>",
"PropertyName": "<string>",
"ActionHint": "<string>",
"DocUrl": "<string>"
}
]
}{
"StatusCode": 100,
"IsSuccess": true,
"Data": null,
"DataContext": {
"TraceId": "<string>"
},
"Notifications": [
{
"Code": "070101",
"Message": "<string>",
"PropertyName": "<string>",
"ActionHint": "<string>",
"DocUrl": "<string>"
}
]
}