# /api/v2/users and api/v2/users-by-email have incorrect & varying behavior

**URL:** <https://community.auth0.com/t/api-v2-users-and-api-v2-users-by-email-have-incorrect-varying-behavior/58236>\
**Category:** Get Help\
**Tags:** users\
**Created:** [February 21, 2021, 6:11pm UTC](https://community.auth0.com/t/api-v2-users-and-api-v2-users-by-email-have-incorrect-varying-behavior/58236 "2021-02-21T18:11:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidhouseknechtdev](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/davidhouseknechtdev/32/12778_2.png) [@davidhouseknechtdev](https://community.auth0.com/u/davidhouseknechtdev)\
**Post date:** [February 21, 2021, 6:11pm UTC](https://community.auth0.com/t/api-v2-users-and-api-v2-users-by-email-have-incorrect-varying-behavior/58236/1 "2021-02-21T18:11:37Z")

</div>

2 issues I am seeing:

## 1st

`/api/v2/users` does not respect `include_fields=false`. Looking at [the docs](https://auth0.com/docs/api/management/v2#!/Users/get_users) it _should_ respect `false`.

Example GET request:

```auto
{{auth0domain}}/api/v2/users?search_engine=v3&q=email:{my-users-email}&fields=nickname,picture&fields_include=false

```

Response:

```json
[
    {
        "nickname": "{my-users-nickname}",
        "picture": "https://s.gravatar.com/avatar/ffe93983af1ad59b7cbf78e75b4b46c0?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fda.png"
    }
]

```

It appears it is always treating my `fields` as `include_fields=true`.

## 2nd

`/api/v2/users-by-email` does not allow the field `last_password_reset`. Looking at [the docs](https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email) it doesn’t say anything about _not_ being able to filter based on `last_password_reset`.

Example GET request:

```auto
{{auth0domain}}/api/v2/users-by-email?email=clark.kent@global.com&include_fields=true&fields=nickname,picture,last_password_reset

```

Response:

```json
{
    "statusCode": 400,
    "error": "Bad Request",
    "message": "Query validation error: 'String 'nickname,picture,last_password_reset' does not match pattern. Must be a comma separated list of the following values: phone_number,email,email_verified,picture,username,user_id,name,nickname,created_at,identities,app_metadata,user_metadata,last_ip,last_login,logins_count,updated_at,blocked,family_name,given_name' on property fields (Comma-separated list of fields to include or exclude (based on value provided for include_fields) in the result. Leave empty to retrieve all fields).",
    "errorCode": "invalid_query_string"
}

```

Is there a reason `last_password_reset` can’t be in the `fields` property? If I don’t have a `fields` query param, the `last_password_reset` value returns just fine with the entire user object.

## Question/Bug

These bugs/behaviors are making it so I cannot use the `fields` param and always have to request the entire user object (which isn’t a deal breaker, just kind of annoying). If I am doing something incorrectly, please let me know and I can adjust. But it seems like these are bugs.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 22, 2021, 6:04pm UTC](https://community.auth0.com/t/api-v2-users-and-api-v2-users-by-email-have-incorrect-varying-behavior/58236/2 "2021-02-22T18:04:03Z")

</div>

Hi @davidhouseknechtdev ,

Welcome to the Community!

> [@davidhouseknechtdev](#):
>
> `/api/v2/users` does not respect `include_fields=false` . Looking at [the docs](https://auth0.com/docs/api/management/v2?_ga=2.71524187.995925066.1614009518-1261373470.1602622721#!/Users/get_users) it _should_ respect `false` .

In your example request you have a mistype. You have requested `fields_include`, it should be `include_fields`. See if that fixes it.

> [@davidhouseknechtdev](#):
>
> `/api/v2/users-by-email` does not allow the field `last_password_reset` . Looking at [the docs](https://auth0.com/docs/api/management/v2#!/Users_By_Email/get_users_by_email) it doesn’t say anything about _not_ being able to filter based on `last_password_reset` .

I am able to get this field without any problem. Does your user have a last\_password\_reset field? i.e. have they ever reset their password? You can see the raw JSON in the dashboard.

---

<div class="post-metadata">

**Author:** ![davidhouseknechtdev](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/davidhouseknechtdev/32/12778_2.png) [@davidhouseknechtdev](https://community.auth0.com/u/davidhouseknechtdev)\
**Post date:** [February 22, 2021, 6:48pm UTC](https://community.auth0.com/t/api-v2-users-and-api-v2-users-by-email-have-incorrect-varying-behavior/58236/3 "2021-02-22T18:48:10Z")

</div>

Thanks, Dan!

## #1

This was totally my oversight! Fixing my dyslectic error is returning the expected results.

## #2

Yes, my user has that field. JSON (reduced for brevity):

```json
{
    // other fields
    "last_password_reset": "2021-02-21T19:30:05.796Z",
    "last_login": "2021-02-21T19:34:07.218Z",
    "logins_count": 3
 }

```

Are you able to get the field using `fields=last_password_reset`? I am able to get that field if I don’t use the `fields` param at all.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [February 22, 2021, 8:37pm UTC](https://community.auth0.com/t/api-v2-users-and-api-v2-users-by-email-have-incorrect-varying-behavior/58236/5 "2021-02-22T20:37:03Z")

</div>

I see what you are saying. It seems the only way to retrieve it is to request the entire object.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 27, 2021, 9:08pm UTC](https://community.auth0.com/t/api-v2-users-and-api-v2-users-by-email-have-incorrect-varying-behavior/58236/6 "2021-04-27T21:08:37Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
