Create a new file resource
POST
/customer-api/v1/file
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");curl_easy_setopt(hnd, CURLOPT_URL, "https://your-instance.seventhings.com/customer-api/v1/file");
struct curl_slist *headers = NULL;headers = curl_slist_append(headers, "Authorization: Bearer <token>");headers = curl_slist_append(headers, "Content-Type: multipart/form-data; boundary=---011000010111000001101001");curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"; filename=\"file\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n");
CURLcode ret = curl_easy_perform(hnd);using System.Net.Http.Headers;var client = new HttpClient();var request = new HttpRequestMessage{ Method = HttpMethod.Post, RequestUri = new Uri("https://your-instance.seventhings.com/customer-api/v1/file"), Headers = { { "Authorization", "Bearer <token>" }, }, Content = new MultipartFormDataContent { new StringContent("") { Headers = { ContentType = new MediaTypeHeaderValue("application/octet-stream"), ContentDisposition = new ContentDispositionHeaderValue("form-data") { Name = "data", FileName = "file", } } }, },};using (var response = await client.SendAsync(request)){ response.EnsureSuccessStatusCode(); var body = await response.Content.ReadAsStringAsync(); Console.WriteLine(body);}package main
import ( "fmt" "strings" "net/http" "io")
func main() {
url := "https://your-instance.seventhings.com/customer-api/v1/file"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"; filename=\"file\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>") req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close() body, _ := io.ReadAll(res.Body)
fmt.Println(res) fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder() .uri(URI.create("https://your-instance.seventhings.com/customer-api/v1/file")) .header("Authorization", "Bearer <token>") .header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") .method("POST", HttpRequest.BodyPublishers.ofString("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"; filename=\"file\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n")) .build();HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());System.out.println(response.body());OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"; filename=\"file\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n");Request request = new Request.Builder() .url("https://your-instance.seventhings.com/customer-api/v1/file") .post(body) .addHeader("Authorization", "Bearer <token>") .addHeader("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") .build();
Response response = client.newCall(request).execute();import axios from 'axios';
const form = new FormData();form.append('data', 'file');
const options = { method: 'POST', url: 'https://your-instance.seventhings.com/customer-api/v1/file', headers: { Authorization: 'Bearer <token>', 'Content-Type': 'multipart/form-data; boundary=---011000010111000001101001' }, data: '[form]'};
try { const { data } = await axios.request(options); console.log(data);} catch (error) { console.error(error);}const url = 'https://your-instance.seventhings.com/customer-api/v1/file';const form = new FormData();form.append('data', 'file');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}val client = OkHttpClient()
val mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001")val body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"; filename=\"file\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n")val request = Request.Builder() .url("https://your-instance.seventhings.com/customer-api/v1/file") .post(body) .addHeader("Authorization", "Bearer <token>") .addHeader("Content-Type", "multipart/form-data; boundary=---011000010111000001101001") .build()
val response = client.newCall(request).execute()<?php
$curl = curl_init();
curl_setopt_array($curl, [ CURLOPT_URL => "https://your-instance.seventhings.com/customer-api/v1/file", 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=\"data\"; filename=\"file\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n", CURLOPT_HTTPHEADER => [ "Authorization: Bearer <token>", "Content-Type: multipart/form-data; boundary=---011000010111000001101001" ],]);
$response = curl_exec($curl);$err = curl_error($curl);
curl_close($curl);
if ($err) { echo "cURL Error #:" . $err;} else { echo $response;}<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://your-instance.seventhings.com/customer-api/v1/file', [ 'multipart' => [ [ 'name' => 'data', 'filename' => 'file', 'contents' => null, 'headers' => [ 'Content-Type' => 'application/octet-stream' ] ] ] 'headers' => [ 'Authorization' => 'Bearer <token>', ],]);
echo $response->getBody();import http.client
conn = http.client.HTTPSConnection("your-instance.seventhings.com")
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"data\"; filename=\"file\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n"
headers = { 'Authorization': "Bearer <token>", 'Content-Type': "multipart/form-data; boundary=---011000010111000001101001"}
conn.request("POST", "/customer-api/v1/file", payload, headers)
res = conn.getresponse()data = res.read()
print(data.decode("utf-8"))import requests
url = "https://your-instance.seventhings.com/customer-api/v1/file"
files = { "data": "open('file', 'rb')" }headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, files=files, headers=headers)
print(response.json())use reqwest;
#[tokio::main]pub async fn main() { let url = "https://your-instance.seventhings.com/customer-api/v1/file";
async fn file_to_part(file_name: &'static str) -> reqwest::multipart::Part { let file = tokio::fs::File::open(file_name).await.unwrap(); let stream = tokio_util::codec::FramedRead::new(file, tokio_util::codec::BytesCodec::new()); let body = reqwest::Body::wrap_stream(stream); reqwest::multipart::Part::stream(body) .file_name(file_name) .mime_str("text/plain").unwrap() }
let form = reqwest::multipart::Form::new() .part("data", file_to_part("file").await); let mut headers = reqwest::header::HeaderMap::new(); headers.insert("Authorization", "Bearer <token>".parse().unwrap());
let client = reqwest::Client::new(); let response = client.post(url) .multipart(form) .headers(headers) .send() .await;
let results = response.unwrap() .json::<serde_json::Value>() .await .unwrap();
dbg!(results);}curl --request POST \ --url https://your-instance.seventhings.com/customer-api/v1/file \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data' \ --form data=@filewget --quiet \ --method POST \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: multipart/form-data; boundary=---011000010111000001101001' \ --body-data '-----011000010111000001101001\r\nContent-Disposition: form-data; name="data"; filename="file"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n' \ --output-document \ - https://your-instance.seventhings.com/customer-api/v1/fileCreate a new file resource
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typemultipart/form-data
Upload a file and create a file resource
object
data
required
string format: binary
Responses
Section titled “Responses”Creation of the file resource has succeeded
Headers
Section titled “Headers”Location
string
The location of the created file
Example
/ultron/api/v1/files/9091afea-81ee-4003-ac76-2ac11e3ddc3fLocation-UUID
uuid
The UUID of the newly created object.
Access token is missing or invalid.
You are not permitted to perform the requested operation.
The requested resource representation has no acceptable format.
Internal Server Error.

