In this tutorial, you will enroll a new user, Jack, in the Visual Chronicle service so he can be assigned a new watch history
.
Expect this tutorial to take about 15 minutes to complete.
You will enroll Jack using Postman, a user-friendly API client. Postman will allow you to easily POST
a new user
resource containing the user’s details.
To enroll a new user:
First confirm our local service is running in the command window with the following:
cd <your-github-workspace>/visual-chronicle/api
# Run the service and monitor its database file for updates
json-server database.json
{base_url}/users
{base_url}
may depends on installation, but is typically http://localhost:3000
Content-Type: application/json
Request body: raw
Property | Description | Type | Required | Notes |
---|---|---|---|---|
name | The user’s name. | string | Required | |
The user’s email. | string | Required | A unique email is required. |
In the Request Body, the JSON script of those properties will be entered like this:
{
"name": "Jack Wilson",
"email": "jack.wilson@example.com"
}
Watch for the response body, which should look something like this. Note that the names should be the same as you used in your Request body and the response should include the new user’s id
.
{
"name": "Jack Wilson",
"email": "jack.wilson@example.com"
"id": 5
}
After doing this tutorial in Postman, you might like to repeat it in your favorite programming language. To do this, adapt the values from the tutorial to the properties and arguments that the language uses to make REST API calls.