# Cannot post to user app metadata after api call on post login flow

**URL:** <https://community.auth0.com/t/cannot-post-to-user-app-metadata-after-api-call-on-post-login-flow/100207>\
**Category:** Get Help\
**Tags:** actions-management-api, management-api\
**Created:** [February 10, 2023, 6:51pm UTC](https://community.auth0.com/t/cannot-post-to-user-app-metadata-after-api-call-on-post-login-flow/100207 "2023-02-10T18:51:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ludvig.bergsaker](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ludvig.bergsaker](https://community.auth0.com/u/ludvig.bergsaker)\
**Post date:** [February 10, 2023, 6:51pm UTC](https://community.auth0.com/t/cannot-post-to-user-app-metadata-after-api-call-on-post-login-flow/100207/1 "2023-02-10T18:51:29Z")

</div>

Hi,

I have a problem where i cannot post to user app metadata after api call in a post login flow. I get to call the api and log the users \_id value, but it will not post it to the users app\_metadata. Here is a image of my post login flow and its response after running.

 ![Capture](https://global.discourse-cdn.com/auth0/original/3X/0/d/0d776fb94b9533478aab97ba4a9e5a81b9ecc6c5.png)

---

<div class="post-metadata">

**Author:** ![ludvig.bergsaker](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ludvig.bergsaker](https://community.auth0.com/u/ludvig.bergsaker)\
**Post date:** [February 10, 2023, 6:52pm UTC](https://community.auth0.com/t/cannot-post-to-user-app-metadata-after-api-call-on-post-login-flow/100207/2 "2023-02-10T18:52:55Z")

</div>

Here is the response from the web console:

###### Commands:

```auto
[
  {
    "key": "mongoId",
    "target": "application",
    "type": "SetMetadata",
    "value": "63e55fa299112b14932a7ec9"
  }
]

```

###### Error:

```auto
{}

```

###### Logs:

```auto
63e55fa299112b14932a7ec9
{
  app_metadata: {},
  created_at: '2023-02-10T18:29:34.706Z',
  email: 'j+smith@example.com',
  email_verified: true,
  family_name: 'Smith',
  given_name: 'John',
  identities: [
    {
      accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gU21pdGgiLCJpYXQiOjE1MTYyMzkwMjJ9.Q_w2AVguPRU2KskCXwR7ZHl09TQXEntfEA8Jj2_Jyew',
      connection: 'Username-Password-Authentication',
      isSocial: false,
      profileData: {},
      provider: 'auth0',
      userId: '5f7c8ec7c33c6c004bbafe82',
      user_id: '5f7c8ec7c33c6c004bbafe82'
    }
  ],
  last_password_reset: '2023-02-10T18:29:34.706Z',
  multifactor: [],
  name: 'j+smith@example.com',
  nickname: 'j+smith',
  phone_number: '18882352699',
  phone_verified: false,
  picture: 'http://www.gravatar.com/avatar/?d=identicon',
  updated_at: '2023-02-10T18:29:34.706Z',
  user_id: 'auth0|5f7c8ec7c33c6c004bbafe82',
  user_metadata: {},
  username: 'jsmith'
}

```

###### Stats:

```auto
{
  "total_request_duration_ms": 205,
  "total_runtime_execution_duration_ms": 200,
  "runtime_processing_duration_ms": 4,
  "action_duration_ms": 158,
  "runtime_external_call_duration_ms": 38,
  "boot_duration_ms": 42,
  "network_duration_ms": 5
}

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [February 10, 2023, 11:01pm UTC](https://community.auth0.com/t/cannot-post-to-user-app-metadata-after-api-call-on-post-login-flow/100207/4 "2023-02-10T23:01:58Z")

</div>

Hi there @ludvig.bergsaker welcome to the community!

Everything looks good to me here - Have you checked the actual user profile in the Auth0 dashboard and/or via the [management API](https://auth0.com/docs/api/management/v2#!/Users/get_users_by_id)? I suspect the `app_metadata` is being added, it’s just not being logged.

Let us know if that’s not the case!

---

<div class="post-metadata">

**Author:** ![ludvig.bergsaker](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ludvig.bergsaker](https://community.auth0.com/u/ludvig.bergsaker)\
**Post date:** [February 11, 2023, 11:19am UTC](https://community.auth0.com/t/cannot-post-to-user-app-metadata-after-api-call-on-post-login-flow/100207/5 "2023-02-11T11:19:39Z")

</div>

Hi, thanks for answering.  
I have checked and it does not add it to the users metadata 😕

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [February 13, 2023, 9:15pm UTC](https://community.auth0.com/t/cannot-post-to-user-app-metadata-after-api-call-on-post-login-flow/100207/6 "2023-02-13T21:15:00Z")

</div>

Thanks for confirming! If you hard code a piece of metadata in your action to add using `setAppMetadata` does that get pushed to your user’s profile correcty?

---

<div class="post-metadata">

**Author:** ![ludvig.bergsaker](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@ludvig.bergsaker](https://community.auth0.com/u/ludvig.bergsaker)\
**Post date:** [February 14, 2023, 9:27am UTC](https://community.auth0.com/t/cannot-post-to-user-app-metadata-after-api-call-on-post-login-flow/100207/7 "2023-02-14T09:27:51Z")

</div>

@ty.frith Yep, if i hard code a value it works. But not with the response from my api

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [February 15, 2023, 6:40pm UTC](https://community.auth0.com/t/cannot-post-to-user-app-metadata-after-api-call-on-post-login-flow/100207/8 "2023-02-15T18:40:06Z")

</div>

Hey @ludvig.bergsaker thanks for confirming - Good to know the Action itself is working at least. I’ve set up a very similar Action with a dummy API and I’m able to get the ID and set it in app metadata without issue. If you go to your tenant settings → advanced → Extensibilty what version of Node are you running?

If you’d like to test my Action out, here it is:

```auto
exports.onExecutePostLogin = async (event, api) => {
  const axios = require('axios');
  const res = await axios.get('https://63ec312631ef61473b1e95c5.mockapi.io/api/v666/users')

  api.user.setAppMetadata("test_metadata", res.data[0].user_id)
};

```

---

<div class="post-metadata">

**Author:** ![ty.frith](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ty.frith/32/58484_2.png) [@ty.frith](https://community.auth0.com/u/ty.frith)\
**Post date:** [March 20, 2023, 3:00pm UTC](https://community.auth0.com/t/cannot-post-to-user-app-metadata-after-api-call-on-post-login-flow/100207/9 "2023-03-20T15:00:16Z")

</div>

This topic was automatically closed after 10 days. New replies are no longer allowed.
