![]() ![]() To "prettify" code means to un-minify it and format it with white space that is readable.įor the sake of variety with GUI clients, here's the same call made in Paw: The Pretty JSON view expands the JSON response into more readable code. Then toggle the options to Pretty and JSON. In Postman, make a request to the weatherdata API. While the first two endpoint responses include text only, the weatherdata endpoint response is in JSON. (Alternatively, click the + button on the new tab and create new tabs each time.) View the format of the weatherdata response in JSON (Otherwise you'll overwrite the settings of the existing request.) Then choose your collection and request name. When you save these other endpoints, click the arrow next to Save and choose Save As. Whereas the first two endpoints (aqi and weather) are text/plain, the Accept header for the weatherdata endpoint is application/json. The Accept header tells the browser what format you will accept the response in. Make requests for the other endpointsĮnter details into Postman for the other two endpoints for the Mashape Weather API: Saved endpoints appear in the left side pane under Collections. In the Request Name box at the top of the dialog box, type a friendly name for the request, such as "AQI endpoint".In the Save Request dialog box, create a new collection (for example, weather) by typing the collection name in the "Or create new collection" box.In Postman, click the Save button (next to Send).Usually the responses are more detailed JSON, which allows you to select a specific part of the response to work with. You can switch the format to HTML, JSON, XML, or other formats, but since this response is text only, you won't see any difference. (Swap in your own API key in place of APIKEY.) If you have additional parameters in the query string, they're joined with an ampersand & symbol.Ĭlick the Headers tab (below the GET button) and insert the key value pairs: Accept: text/plain and X-Mashape-Key: APIKEY. A request URL only has one query string (one ?). The query string is the code followed by the ? in the endpoint URL. ![]() When you add these lat and lng parameters, they will dynamically be added as a query string to the endpoint URI. You can find latitude and longitude values from the URL in Google Maps when you go to a specific location. If the country isn't supported, you'll see "Not supported" in the API response. Only some countries are supported in the aqi call - specifically the United States, Singapore, Malaysia, Europe, and Australia. ![]() Insert the endpoint into the main box (next to the method, which is GET by default): Ĭlick the Params button (to the right of the box where you inserted the endpoint) and insert lat and lng parameters with specific values (other than 1).You'll make a REST call for the first endpoint ( aqi) in the Mashape Weather API.(Note that you must also have Chrome to run the Chrome app.) If you're on Windows, choose the Chrome app. If you haven't already done so, download and install the at If you're on a Mac, choose the Mac app.When we deep dive into these points later, things will be a lot clearer. So if it seems like I'm glossing over concepts things now, like what a GET method is or a resource URL, hang in there. After you do an activity, we'll explore the concepts in more depth. ![]() In this course, I'm following more of an act-first-then-understand type of methodology. Learn by doing, then deep dive into conceptsĪ lot of times abstract concepts don't make sense until you can contextualize them with some kind of action. Of the various GUI clients available, I think Postman is the best option, since it allows you to save both calls and responses, is free, works on both Mac and PC, and is easy to configure.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |