Score:1

How can I get the user UUID using the JSON API?

cn flag
blu

I tried the following JSON API query strings to get the UUID, but I keep getting a 404 error.

  • {url}/jsonapi/user/user?filter[uid][value]={uid}
  • {url}/jsonapi/user/user/{uid}
  • {url}/jsonapi/user/user?filter%5Banon%5D%5Bcondition%5D%5Bpath%5D=uid&filter%5Banon%5D%5Bcondition%5D%5Bvalue%5D=0&filter%5Banon%5D%5Bcondition%5D%5Boperator%5D=%3C%3E

EDIT:

Forgot to include this route: {url}/user/{uid}

id flag
Is /jsonapi/user/user a route?
id flag
I think that it is. What jsonapi setup have you done and what are you using to authenticate to the API?
cn flag
blu
It's set to Accept all JSON:API. In REST server settings User is enabled but the route it defines also doesn't work. EDIT: using basic_auth
id flag
I can't reproduce what you have reported. Is the jsonapi module enabled? Does *any* jsonapi route work on the site? Is only this route missing? What does `vendor/bin/drush route` show regarding jsonapi routes? Is see /jsonapi/user/user there, and it works.
Score:0
cn flag

I'm confused whether you want the UUID as suggested in the question title or the UID as suggested in your code.

UID

By default, it's drupal_internal__uid, not uid.

You can confirm this by visiting /jsonapi/user/user and checking the output.

For example:

https://example.ddev.site/jsonapi/user/user?&filter[drupal_internal__uid]=3

If you want to shorten drupal_internal__uid to uid, you can install the JSON:API Extras module and configure an override for the User resource.

UUID

In JSON:API, the UUID is always id regardless of what kind of entity you have:

https://example.ddev.site/jsonapi/user/user?&filter[id]=2e5bcb94-574d-424b-98a7-2dd450c51a2c

Finding out the names of stuff in JSON:API

You can use the JSON:API Explorer module to check out the JSON output visually.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.