Upload photo

Upload a photo for the current user. This function is only available through a JWT token. 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

JWT_TOKEN = 'YOUR_JWT_TOKEN'

r = requests.post(
    'https://studio.edgeimpulse.com/v1/api/user/photo',
    cookies={
        'jwt': JWT_TOKEN
    },
    files=(
        ('photo', ('Jan-Jongboom.jpg', open('/Users/janjongboom/Downloads/Jan-Jongboom.jpg', 'rb'), 'image/jpeg')),
    )
)

print('returned', r, r.content)
curl -X POST https://studio.edgeimpulse.com/v1/api/user/photo \
    -b "jwt=YOUR_JWT_TOKEN" \
    -F [email protected]/Users/janjongboom/Downloads/Jan-Jongboom.jpg
const request = require('request');
const fs = require('fs');

const JWT_TOKEN = 'YOUR_JWT_TOKEN';

// Make the request with an empty 'formData' object, so we can manipulate this later
let req = request.post(`https://studio.edgeimpulse.com/v1/api/user/photo`, {
    headers: {
        'Content-Type': 'multipart/form-data',
        'Cookie': 'jwt=' + JWT_TOKEN
    },
    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('photo', fs.readFileSync('/Users/janjongboom/Downloads/Jan-Jongboom.jpg'), {
    contentType: 'image/jpeg',
    filename: 'Jan-Jongboom.jpg'
});
Language
Authentication
Click Try It! to start a request and see the response here!