34 lines
2.9 KiB
Plaintext
34 lines
2.9 KiB
Plaintext
SEN-103 Programming Multi-Module Applications
|
|
|
|
Lab 5 Practice Assignment
|
|
|
|
Using REST APIs with Postman
|
|
|
|
|
|
|
|
Overview
|
|
|
|
Understanding how to construct and to use a set of REST API endpoints is a critical skill for building modern distributed applications. This lab exercise gives you practice executing HTTP requests using the Postman utility, a widely-used tool for exploring, building and debugging REST APIs.
|
|
|
|
|
|
|
|
Instructions
|
|
|
|
1. Go to https://www.postman.comLinks to an external site. and sign up for a free account if you do not already have one. Go to My Workspace. Click on New, then choose HTTP. Postman gives you a form for setting up your HTTP request.
|
|
|
|
2. Open a Word/LibreOffice/GoogleDocs document that you can use to save and submit the results of your work. Write your nickname and the date at the top.
|
|
|
|
3. Go to https://open-meteo.com/en/docsLinks to an external site. This site provides a free REST API for getting weather data about a location or set of locations. This API provides only a single endpoint, a GET request with the base URL https://api.open-meteo.com/v1/forecast However, you can specify a very large number of different parameters, including the location (or a set of locations), the weather variables in which you are interested, the reporting interval, etc. The possibilities are all documented on the site.
|
|
|
|
4. Create a request in Postman to access the Open-Meteo API and return the temperature and the relative humidity for the area near CMKL, hourly for the next seven days. Use the latitude/longitude coordinates 13.7243333, 100.7701839 and the time zone Asia/Bangkok.
|
|
|
|
5. Execute your request in Postman. When you get it to execute successfully (this may take a few tries), copy and paste the full request URL into your document. Then copy and paste the JSON response which Postman displays. Do you understand the contents of this response?
|
|
|
|
6. Modify your request to ask for the temperature, the cloud cover and rainfall in Boston (latitude 42.364506, longitude 71.038887) for the date range 2024-02-08 through 2024-02-14. When you get your request to execute successfully, copy and paste both the full request and the response into your document.
|
|
|
|
7. Next we will use https://timeapi.io to create a POST request that will convert a time from one timezone to another. Go to https://timeapi.io/swagger/index.htmlLinks to an external site. Use the documentation to figure out how to create a request using the /api/Conversion/ConvertTimeZone endpoint. Note that for a POST request, you must provide the arguments to the API using a Body, which is a snippet of data in JSON format. You can find examples in the timeapi.io documentation. Convert the current time in Bangkok to the equivalent time in Boston. Then convert the current time in Bangkok to the the equivalent time in London.
|
|
|
|
8. Copy and paste the full request, the body, and the response into your document, for each of these requests.
|
|
|
|
9. Upload your document in PDF format.
|