Create a driver's schedule
Let's suppose that you've enrolled SallyAnn (Nana) in the service, and you want to create a driving schedule for her. She's offered to drive her grandson, Johnny, to and from a dental appointment.
In this tutorial, you will learn how to create a pick-up and drop-off schedule for a driver in the service.
Expect this tutorial to take about 15 minutes to complete.
Before you start
Before you start this tutorial:
- Complete all the prerequisites on the development system you'll use for the tutorial.
- Open the Postman app, which you'll use to test your API calls.
About this task
There's two parts to this task.
- Identify the driver's ID — unless you already know the driver's unique ID, you must first retrieve it from the list of available drivers. If you already know the driver’s ID, skip this step.
- Create a driving schedule to associate with the returned/known driver's ID.
Identify a driver's ID
To view all drivers, make a GET
call to the drivers
resource.
- To create a new request in Postman, click New > HTTP. Give the request a title.
-
Specify these request values in the right-frame window:
UI Element Values Required Notes METHOD GET Required Locate the drop-down menu next to the URL field. URL {server_url}/drivers
Required All drivers are returned unless you specify query parameters (see params) to return a specific driver. params Key/Value
Optional You can specify driver attributes as key/value query parameters. For example: driverIdentity/Nana. Note that key/value titles are case sensitive. Headers Content-Type
Optional The format of the data to be posted. Default value is application/json. Request body None -
Click Send to make the request.
-
Review the response body and verify the driver's id, which is automatically generated when the driver object is created. The response should look something like this.
Create a schedule for an identified driver
Assuming that you know Nana's driver's {id}, proceed to create a driving schedule for her.
Make a POST
call to the schedules
resource.
- To create a new request in Postman, click New > HTTP. Give the request a title.
-
Specify these values in the right-frame window:
UI Element Values Required Notes METHOD POST Required Locate the drop-down menu next to the URL field. URL {server_url}/schedules
Required Headers Content-Type
Optional The format of the data to be posted. Default value is application/json. -
In the request body, POST a JSON representation of Nana's
schedules
object like this. The driverId is the id you identified in your previousGET
call to thedrivers
resource, if not already known. You can change the values of each property as you’d like. -
Click Send to make the request.
-
Review the response body and verify that the driver's schedule includes a newly generated id. A 200 OK status code indicates success.