I'm trying to update device via API request with PUT method,
But the error 400 always returns me, I've checked the authentication user and it's right.
this error only occurs with the PUT method.
Code:
const updateEntity = (id, newData, entity) => {
const userEncode = base64.encode('user' + ':' + 'password');
const requestOptions = {
method: 'PUT',
headers: {
"Authorization": `Basic ${userEncode}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(newData),
};
fetch(`http://207.180.198.226:8082/api/${entity}/${id}`, requestOptions)
.then((response) => console.log(response));
};
updateEntity(512, {"model": "TK311C"}, 'devices');
You have to send full model.
It worked, Thanks!
I realized that it is mandatory to pass in the body the keys "id", "name" and "uniqueId".
Once again, you have to pass the whole model, not just some specific fields.
I'm trying to update device via API request with PUT method,
But the error 400 always returns me, I've checked the authentication user and it's right.
this error only occurs with the PUT method.
Code: