I'm trying to use following Auth0 API call: https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id
const sUserMetadata = async () => {
const domain = "xxxxxxxxxxxxxxx"
try {
const accessToken = await getAccessTokenSilently({
audience: `${domain}/api/v2/`,
scope: "update:current_user_metadata",
});
const userDetailsByIdUrl = `${domain}/api/v2/users/${user.sub}`;
const metadataResponse = await fetch(userDetailsByIdUrl, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${accessToken}`,
},
body: { "email_verified": true }
})
let user_metadata = await metadataResponse;
console.log(user_metadata)
} catch (e) {
console.log(e.message);
}
};
sUserMetadata().then(r => null);
I am receiving following response error:
{"statusCode":400,"error":"Bad Request","message":"Payload validation error: 'Expected type object but found type string'.","errorCode":"invalid_body"}
Obviously the Body-Tag provides it in the correct form with Bracets {} so it Should! be an Object.
I have tried:
JSON.parse()
I have tried to add Content-Type which results in a freaking "SYNTAX ERROR" because of the
-incontent-typewhich doesnt make any sense because under chrome debugger I can obviously see that there is a property calledcontent-type: text/plain;charset=UTF-8and I have no idea how else I am supposed to change this?headers: { Authorization: `Bearer ${accessToken}`, Content-Type: 'application/json', },