In my react app project I am sending a formdata post by axios to a local web api service on .net core 6. The formData has a file and a folder name appended properties but the request to the service returns : AxiosError: Request failed with status code 400 [1] at settle (file:///D:/Documents/React/psarchetypeeditor/node_modules/axios/lib/core/settle.js:19:12) [1] at IncomingMessage.handleStreamEnd (file:///D:/Documents/React/psarchetypeeditor/node_modules/axios/lib/adapters/http.js:570:11) [1] at IncomingMessage.emit (node:events:525:35) [1] at endReadableNT (node:internal/streams/readable:1359:12) [1] at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { [1] code: 'ERR_BAD_REQUEST', this is my post code :
const formData = new FormData();
formData.append('folder', folder);
formData.append('file', file);
console.log("formData")
await axios.post('https://localhost:7275/Upload', formData, {
headers: {
"Content-Type": 'multipart/form-data'
},
withCredentials: true,
httpsAgent: new https.Agent({rejectUnauthorized: false,}),
}).then((response) => {
console.log("Response Data : " + response.data);
res.json(response.data);
}).catch ((error) => {
console.error('Upload proxy error: ', error);
return res.status(500).send('Upload proxy error');
})
})
What would be the problem and how should exactly be the service to get this type of information?