In this tutorial, we are going to create a SAP MII application to display weather forecast information using an API. I have used OpenWeatherMap service to implement this with SAP MII. We will just grab the weather information provided by the API and display it in the application.
This is one of the best API service that provides weather forecast. It provides tremendous volume of weather data regularly. It is a free service with limited access. For basic usage, it should be sufficient and for advanced you may have to pay for it. Integrating this API with a SAP MII application is easy. The following three steps are used for the integration.
By clicking the below link, the cities name will be given in a url. Unzip the file and get the id of the city/state.
This is the Transcation to request the OpenWeatherMap service to get the weather forecasts. While sending the request, the API key and the city id is sent with request URL query string. I used TEXT LOADER to send the API request. It response will be in a JSON format. we can get the weather data.
This XML code is used to display the weather forecast by decoding the JSON object response. In this section, we access the location, weather description, icon, min-max ranges of the temperature, humidity and wind speed.