Andrew Fletcher published: 16 May 2022 3 minutes read
The user API, was originally created under the General Documenation area (see Query - user). I'm creating a new user API document under the API documentation area.
Calling a query
To call a user query the details are required:
- User uid;
- Authentication credentials
The query string is: {domain}/user/{uid}?_format=hal_json
See the notes on set up, for the staging and production URLs. Using the current staging URL in the set up screen, as example of the query string using the following criteria
Replacing the following variables:
- {domain} ~ stg.runningrival.com
- {uid} ~ 3
https://your-site.com/user/3?_format=hal_json
Example of the json output
{
"_links": {
"self": {
"href": "https://your-site.com/user/3?_format=hal_json"
},
"type": {
"href": "https://your-site.com/rest/type/user/user"
}
},
"uid": [
{
"value": "3"
}
],
"uuid": [
{
"value": "2b167e74-11a0-4097-9de4-d49c8338e7c9"
}
],
"langcode": [
{
"value": "en",
"lang": "en"
}
],
"preferred_langcode": [
{
"value": "en"
}
],
"preferred_admin_langcode": [
{
"value": "en"
}
],
"name": [
{
"value": "rest"
}
],
"mail": [
{
"value": "test@your-site.com"
}
],
"timezone": [
{
"value": "Australia/Melbourne"
}
],
"status": [
{
"value": "1"
}
],
"created": [
{
"value": "1467306433"
}
],
"changed": [
{
"value": "1476503227",
"lang": "en"
}
],
"access": [
{
"value": "1490331462"
}
],
"login": [
{
"value": "1477037554"
}
],
"init": [
{
"value": "test@your-site.com"
}
],
"roles": [
{
"target_id": "administrator"
}
],
"default_langcode": [
{
"value": "1",
"lang": "en"
}
],
"field_firstname": [
{
"value": "Bill"
}
],
"field_gender": [
{
"value": "male"
}
],
"field_lastname": [
{
"value": "Caravans"
}
],
"field_mobile": [
{
"value": "04121212"
}
]
}
Related articles
Andrew Fletcher
•
04 Apr 2025
Managing .gitignore changes
When working with Git, the .gitignore file plays a critical role in controlling which files and folders are tracked by version control. Yet, many developers are unsure when changes to .gitignore take effect and how to manage files that are already being tracked. This uncertainty can lead to...
Andrew Fletcher
•
26 Mar 2025
How to fix the ‘Undefined function t’ error in Drupal 10 or 11 code
Upgrading to Drupal 10.4+ you might have noticed a warning in their code editor stating “Undefined function ‘t’”. While Drupal’s `t()` function remains valid in procedural code, some language analysis tools — such as Intelephense — do not automatically recognise Drupal’s global functions. This...
Andrew Fletcher
•
17 Mar 2025
Upgrading to PHP 8.4 challenges with Drupal contrib modules
The upgrade from PHP 8.3.14 to PHP 8.4.4 presents challenges for Drupal 10.4 websites, particularly when dealing with contributed modules. While Drupal core operates seamlessly, various contrib modules have not yet been updated to accommodate changes introduced in PHP 8.4.x. This has resulted in...