There is no problem with sending photos from Postman.
header is ---> 'Content-Type':'application/x-www-form-urlencoded'
body is ----> form-data , {file : image..}
Sending headers to x-www-form-urlencoded or multi-part/form-data does not work.
(HTTP Status 400 – Bad Request)
Note that there is no image capacity limitation in the API. Check out the screenshot for more postman.
I stay overnight for a few days. Please help me....
in my code
let localUri = this.state.image; // <--- is image uri.
let filename = localUri.split('/').pop();
let match = /\.(\w+)$/.exec(filename);
let type = match ? `image/${match[1]}` : `image`;
let formData = new FormData();
formData.append('photo', { file: localUri, name: filename, type: type });
return fetch(MY_SERVER, {
method: 'POST',
body: formData,
headers: {
'Content-Type':'application/x-www-form-urlencoded'
},
}).then((response) => response.text())
.then((responseData) => {
console.log(responseData);
console.log('file',formData)
})
.done();
in error messege I don't think I can find the key called file. Is this an API issue?
HTTP Status 400 – Bad Request
Required request part 'file' is not present