# Cannot update user info

**URL:** <https://community.auth0.com/t/cannot-update-user-info/78781>\
**Category:** Get Help\
**Tags:** api\
**Created:** [February 23, 2022, 2:57pm UTC](https://community.auth0.com/t/cannot-update-user-info/78781 "2022-02-23T14:57:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![melanie.alexandra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/melanie.alexandra/32/33322_2.png) [@melanie.alexandra](https://community.auth0.com/u/melanie.alexandra)\
**Post date:** [February 23, 2022, 2:57pm UTC](https://community.auth0.com/t/cannot-update-user-info/78781/1 "2022-02-23T14:57:26Z")

</div>

I want to update a single user from my api.

I have a function in Express:

```auto
const updateUserAuth0 = async (req, res, next) => {
      var _token = await req.token.access_token;
      var apiToken = "Bearer " + JSON.stringify(_token).replace(/['"]+/g, "");

      var apiOptions = {
        method: "PATCH",
        url:
          "https://myurl.eu.auth0.com/api/v2/users/{" +
          new_user_id +
          "}",
        headers: {
          authorization: apiToken,
          "content-type": "application/json",
        },
        body: {
          family_name: "Newfamily",
        },
      };

      axios
        .request(apiOptions)
        .then(function (response) {
          req.allUsers = response.data.user_id;
          next();
        })
        .catch((err) => {
          console.log("ERROR RESPONSE", err.response.status);

          if (err.response.status === 409) {
            res.sendStatus(409);
          }
          next(err);
        });
    };

```

I call this function and pass it an access token with scopes “read:users update:users create:users read:users\_app\_metadata update:users\_app\_metadata create:users\_app\_metadata update:roles read:organizations update:organizations create:organization\_members read:organization\_members”

On the Auth0 Management API dashboard page on Machine to Machine Applications tab I clicked the down arrow on the API and updated to add the permissions on the access token.

On the MyAPI dashboard page on Machine to Machine Applications tab I clicked the down arrow on the API and updated to add the permissions on the access token.

On the user I am accessing myApi with, I allow all these permissions for myApi and the Auth0 Mgmt API

I have clicked and allowed everything available! I have no idea why I can’t change the user properties with the request as outlined in the mgmt api v2 docs

All I get is 400 - sometimes 404 as I change between slightly different syntax - what am I doing wrong?

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [February 23, 2022, 9:16pm UTC](https://community.auth0.com/t/cannot-update-user-info/78781/3 "2022-02-23T21:16:23Z")

</div>

Hi @melanie.alexandra,

Thank you for reaching out to Auth0 Community!

I noticed in your example the user\_id appended the curly brackets in the URL, but instead, should follow the {identity provider id}|{unique id in the provider} [format](https://auth0.com/docs/manage-users/user-accounts/identify-users).

For example: if the user id is auth0|1234567890, the url should be like  
`https://myurl.eu.auth0.com/api/v2/users/auth0|1234567890`

In this case, please change it to  
`url: "https://myurl.eu.auth0.com/api/v2/users/" + new_user_id,`

Also,  
`body: { family_name: "Newfamily", }`  
should be  
`data: { family_name: "Newfamily", }`

Please give it a try and keep us updated on how it goes. Thanks!

---

<div class="post-metadata">

**Author:** ![melanie.alexandra](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/melanie.alexandra/32/33322_2.png) [@melanie.alexandra](https://community.auth0.com/u/melanie.alexandra)\
**Post date:** [February 24, 2022, 9:30am UTC](https://community.auth0.com/t/cannot-update-user-info/78781/4 "2022-02-24T09:30:40Z")

</div>

Thanks, I tried that and I can make it work. Can a user change their own user profile? How about if the user I want to change has google-oauth2 user id? I still get Bad Request when I log in with google-oauth2 and try to change my own profile, and I want to know the reason because I couldn’t find it in the docs?

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [February 24, 2022, 10:50pm UTC](https://community.auth0.com/t/cannot-update-user-info/78781/6 "2022-02-24T22:50:39Z")

</div>

Hi @melanie.alexandra ,

Thank you for the updates.

> Can a user change their own user profile?

Yes, user can update their user profile from the hosting page. Developers can update the user profiles from the [Management API](https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id).

> How about if the user I want to change has google-oauth2 user id? I still get Bad Request when I log in with google-oauth2 and try to change my own profile, and I want to know the reason because I couldn’t find it in the docs?

Updating user profile data only works for users with “Username-Password-Authentications” connection, that is, users stored in Auth0 database. That’s why you received the error when trying with google-oauth2.

Any other queries we can assist with?

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 22, 2022, 9:26am UTC](https://community.auth0.com/t/cannot-update-user-info/78781/7 "2022-12-22T09:26:23Z")

</div>


