Add files

Add a new file to an existing data item. Don't trust the code generated by the widget, there are examples of using this API in Python, cURL and Node.js under the parameters.

This API requires multipart form data to be posted, which our documentation cannot properly render. This is how you call the API in a variety of languages:

import requests, io

ORGANIZATION_ID = 1
DATA_ITEM_ID = 1000
API_KEY = 'ei_...'

r = requests.post(
    'https://studio.edgeimpulse.com/v1/api/organizations/' + ORGANIZATION_ID + '/data/' + DATA_ITEM_ID + '/add',
    headers={
        'x-api-key': API_KEY
    },
    files=(
        ('files[]', ('hello.txt', open('/Users/janjongboom/Downloads/hello.txt', 'rb'), 'text/plain')),
    )
)

print('returned', r, r.content)
curl -X POST -H "x-api-key: ei_YOUR_API_KEY" \
    https://studio.edgeimpulse.com/v1/api/organizations/ORGANIZATION_ID/data/DATA_ITEM_ID/add \
    -F files[][email protected]/Users/janjongboom/Downloads/hello.txt
const request = require('request');
const fs = require('fs');

const ORGANIZATION_ID = 1;
const DATA_ITEM_ID = 1000;
const API_KEY = 'ei_YOUR_API_KEY';

// Make the request with an empty 'formData' object, so we can manipulate this later
let req = request.post(`https://studio.edgeimpulse.com/v1/api/organizations/${ORGANIZATION_ID}/data/${DATA_ITEM_ID}/add`, {
    headers: {
        'Content-Type': 'multipart/form-data',
        'x-api-key': API_KEY
    },
    formData: { }
}, (_err, resp, body) => {
    if (_err) {
        return console.error('Error when doing request', _err);
    }
    else if (resp.statusCode !== 200) {
        return console.error('statusCode was not 200, but ' + resp.statusCode);
    }
    else {
        console.log('Request succeeded', body);
    }
});

// the request actually gets sent at the next tick so we can still manipulate this
let form = req.form();
form.append('files[]', fs.readFileSync('/Users/janjongboom/Downloads/hello.txt'), {
    contentType: 'text/plain',
    filename: 'hello.txt'
});
Language
Authentication
Click Try It! to start a request and see the response here!