Using the WebRequest activity
Hi,
Does anyone have an example of how to use the WebRequest activity correctly. I have the following service url http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=f80d6b093676ec16e8bda89155592e43 which returns teh following within a browser
{
"coord":
{
"lon": ?-0.13,
"lat": ?51.51
},
"weather":
[
{
"id": ?521,
"main": "Rain",
"description": "shower rain",
"icon": "09d"
}
],
"base": "cmc stations",
"main":
{
"temp": ?284.24,
"pressure": ?1012,
"humidity": ?34,
"temp_min": ?281.15,
"temp_max": ?288.71
},
"wind":
{
"speed": ?2.1
},
"clouds":
{
"all": ?20
},
"dt": ?1461768437,
"sys":
{
"type": ?1,
"id": ?5091,
"message": ?0.0084,
"country": "GB",
"sunrise": ?1461731892,
"sunset": ?1461784733
},
"id": ?2643743,
"name": "London",
"cod": ?200
}
But what do I need to do, to make sure that the results are parsed in the workflow correctly.Thanks
Halil
0
-
Hi Halil,
If you use the web request activity, you can take the result and use it in GetTextFromBytes, and the result from that activity will be your JSON response. You can then use the GetJsonValue activity to get the values you are looking for. The GetJsonValue uses JPATH to allow you to pull out values from the JSON heirarchy.
If you put "base" in the Path argument for the GetJsonValue activity, you would get a string = cmc stations. Parsing out values deeper in, or getting a specific value from an array is slightly trickier but the documentation on JPATH is pretty good.
Good luck.
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
1 kommentar