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
•
22 Apr 2024
Streamlined Drupal 10 Deployment: Best Practices for Stability and Security
Have you ever walked into a situation and marveled at how a site is still operational? Deployments that are riddled with fail-safes piled atop a shaky foundation. The real challenge lies in gradually persuading the team to embrace change to build a stable, robust deployment process aligned with...
Andrew Fletcher
•
21 Apr 2024
This command will help you spot any unusually large directories
The red flag was when I saw the server disk space is showing a site is taking up 57992.5 MB, where locally the site size is showing 957MB. There is something serious happening here and I need to establish the problem quickly. When dealing with a significant discrepancy in site size...
Andrew Fletcher
•
19 Apr 2024
Extending a Contrib Module's Configuration in Drupal 10: A Case Study with Sitewide Alert
Extending the functionality of a contrib module in Drupal can enhance its usefulness without altering the original codebase. This article provides a step-by-step guide on how to add custom configuration options to an existing contrib module, using the sitewide_alert module as an example. We will...