I
Immich•2y ago
DeMASKe

API - Upload a picture

Hello, sorry, I begin my utilisation of Immich. I try some things with the API, and now I try to import a picture. I'm working with python and my response is "{"statusCode":400,"message":"Multipart: Boundary not found","error":"Bad Request"}". I know that error 400 corresponds with a bad request, but I don't know what I should change... Someone, more experimented than me, can help me ?
9 Replies
jrasm91
jrasm91•2y ago
Can you pass files as a dictionary instead? And no data/payload
jrasm91
jrasm91•2y ago
By the way, we have a swagger spec file (open API spec json) you can use to auto generate python code: https://openapi-generator.tech/#try
Hello from OpenAPI Generator | OpenAPI Generator
Description will go into a meta tag in
DeMASKe
DeMASKeOP•2y ago
I'm not sure. Like that ? Can you make me an example ?
DeMASKe
DeMASKeOP•2y ago
I just try to import a photo, whatever the way to do it.
IVPathfinder
IVPathfinder•2y ago
Try remove the content type header? I'm not 100% sure, but that's what basic googling tells me
bo0tzz
bo0tzz•2y ago
What are you trying to make?
DeMASKe
DeMASKeOP•2y ago
To tell you the truth, I'm exploring the API a bit, and I'm trying to import a photo from my computer to Immich, then put it in an album. I know a bit about python so I started there.
Sonorc
Sonorc•5mo ago
Hello, the current uploadAsset doesn't work? I want to upload an image via node js and I always get an error message.
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('assetData', fs.createReadStream('H:\\Git\\bilder\\Neu\\backend\\uploads\\1351335.png'));

data.append('deviceAssetId', '');
data.append('deviceId', '');
data.append('duration', '');


let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'http://127.0.0.1:8980/api/assets?key=z8vuYdyn3loVPP8DhBx6S0Zh2aKiU3T8CzVoT7jDZIs',
headers: {
'Content-Type': 'multipart/form-data',
'Accept': 'application/json',
...data.getHeaders()
},
data : data
};


axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
const axios = require('axios');
const FormData = require('form-data');
const fs = require('fs');
let data = new FormData();
data.append('assetData', fs.createReadStream('H:\\Git\\bilder\\Neu\\backend\\uploads\\1351335.png'));

data.append('deviceAssetId', '');
data.append('deviceId', '');
data.append('duration', '');


let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'http://127.0.0.1:8980/api/assets?key=z8vuYdyn3loVPP8DhBx6S0Zh2aKiU3T8CzVoT7jDZIs',
headers: {
'Content-Type': 'multipart/form-data',
'Accept': 'application/json',
...data.getHeaders()
},
data : data
};


axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
data: { message: 'Invalid share key', error: 'Unauthorized', statusCode: 401, correlationId: '0ikytt67' }
Mraedis
Mraedis•5mo ago
Please don't revive ancient topics. @Sonorc I'm not accepting any DM's for support stuff, feel free to make your own thread here though 🙂

Did you find this page helpful?