-
Notifications
You must be signed in to change notification settings - Fork 1
5.3 Using the Entire Application
Go back to 5.1 Visited State Model
With the entire application built we can now make REST calls to see it at work.
Even if you created a user in Step 4.5, the update to the step5 branch would have deleted the user. So let's recreate John Doe by issuing a POST request to http://localhost/cougar_tutorial/services/user with the following body:
{"givenName":"John",
"lastName":"Doe",
"emailAddress":"john.doe@example.com",
"password":"Password"
}If you created John Doe exactly as listed above, you may pass the following header to provide his credentials:
Authorization: Basic am9obi5kb2VAZXhhbXBsZS5jb206UGFzc3dvcmQ=
Now, we can add a few states John Doe has visited by doing POST or PUT calls to either of the URIs. Let's say John Doe has visited California, New York and Florida. Perform a POST with his authorization header to the following URLs:
- http://localhost/cougar_tutorial/services/user/visited/CA
- http://localhost/cougar_tutorial/services/state/NY/visited
- http://localhost/cougar_tutorial/services/state/FL/visited
Now let's get the list of states John has visited (don't forget the authorization header):
Now let's get the list of visitors to the state of New York
This call will return two different object types depending on whether the authentication was successful. If you provided the header you should the name and email address of John Doe. Otherwise, it will simply return the count of visitors to the state.
Continue to Conclusion