400 while updating user_metadata

Hello,
I’ve also got my app working yet I’m encountering a 400 response when trying to use the Management API to update a user’s metadata.
So first I’m grabbing the authToken using the below POST:

function retrieveAuthAPIToken() {
    var options = {
        method: 'POST',
        url: 'https://harlow777.us.auth0.com/oauth/token',
        headers: {'content-type': 'application/json'},
        data: {
            grant_type: 'client_credentials',
            client_id: 'fiEPVos93440A4u7lROfpUZ3tXTGEP7W',
            client_secret: '<secret>',
            audience: 'https://harlow777.us.auth0.com/api/v2/'
        }
    };
    axios.request(options).then(function (response) {
        console.log(response.data);
        return response.data.access_token;
    }).catch(function(error) {
        console.error(error);
        return null;
    });
}

Then I attempt to update the logged in user’s metadata using this PATCH:

function addCardToUserMetadata(user, authToken) {
    var options = {
        method: 'PATCH',
        url: 'https://harlow777.us.auth0.com/api/v2/users/' + user.sub,
        headers: {authorization: 'Bearer ' + authToken,'content-type': 'application/json'},
        data: {
            user_metadata: {
                creature_collection:'1000'
            }
        }
    };
    axios.request(options).then(function (response) {
        console.log(response.data);
    }).catch(function(error) {
        console.error(error);
    }); 
}    

This PATCH works when I run it as a cURL command but in the code it receives a 400 response. Any ideas on why this would happen?

Hi @Harlow777,

Welcome to the Community!

Sometimes there will be a message that indicates why the 400 is returned. Do you see any messages in your tenant logs?