Hello
I try to make post call to api to update user information but im getting error:
- error: “Bad Request”
- errorCode: “invalid_body”
- message: “Payload validation error: ‘Expected type object but found type string’.”
- statusCode: 400
Here’s my update function →
const postUserMetadata = async () => {
try {
const accessToken = await getAccessTokenSilently({
audience: `https://${domain}/api/v2/`,
scope: "update:users",
});
const userDetailsByIdUrl = `https://${domain}/api/v2/users/${user.sub}`;
const metadataResponse = await fetch(userDetailsByIdUrl, {
body:{
“user_metadata”: {
“addresses”: {
“work_address”: “100 Industrial Way”,
“home_address”: “742 Evergreen Terrace”
}
}
},
headers: {
Authorization: `Bearer ${accessToken}`,
},
method: 'PATCH',
});
const { user_metadata } = await metadataResponse.json();
} catch (e) {
console.log(e.message);
}
};
I’ve tried to add “Content-Type”: “application/json”
to header but then i got different error
“Invalid request payload JSON format”
when i store data which i want to send to api to variable as a object and check its type it’s clearly
says that’s object so what’s wrong ?