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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |