Retrieve a driver's schedule
Let's suppose that Mom, Laura, wants a list of her scheduled driving commitments.
In this tutorial, you will learn how to retrieve schedules with a requested status for a specific driver in the service.
Expect this tutorial to take about 15 minutes to complete.
Before you start
- 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.
- Retrieve the scheduled driving commitments associated 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/Mom. 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 should look something like this.
Retrieve the driver's scheduled driving commitments
Assuming that you know the driver's {id}, proceed to retrieve their scheduled driving commitments.
Make a GET
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 GET Required Locate the drop-down menu next to the URL field. URL {server_url}/schedules
Required All schedules are returned unless you specify query parameters (see params) to return a specific schedule. Params Key/Value
Required Specify these key/value query parameters:
* driverId/{id} of the selected driver returned in yourGET
call, and
* status/Scheduled
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 schedules, which should look something like this. A 200 OK status code indicates success.
[ { "driverId": "1", "title": "School run", "passenger": "Molly", "pickupLocation": "789 Oak St, Anytown", "dropoffLocation": "321 Maple St, Anytown", "pickupTime": "2024-06-16T09:00:00Z", "dropoffTime": "2024-06-16T09:30:00Z", "status": "Scheduled", "id": "2" }, { "driverId": "1", "title": "Vet visit", "passenger": "Minnie", "pickupLocation": "123 Main St, Springfield", "dropoffLocation": "12 Animal Drive, Springfield", "pickupTime": "2024-08-08T08:00:00Z", "dropoffTime": "2024-08-08T08:30:00Z", "status": "Scheduled", "id": "4" } ]