Update SharePoint hyperlink pictures with Flow and the Send an HTTP request to SharePoint

This blog post illustrates a workaround to a (very very old) bug in the SharePoint connector; it also illustrates how to update SharePoint items with the Send an HTTP Request to SharePoint.

Let say you have the following SharePoint list  with a list of cities, and you want to create a scheduled  hourly Flow that will go through all cities, that will grab the weather in this location, that will display the Temperature + an icon illustrating the weather :

final

 

The hyperlink field must have the option Format URL as a picture :

hyperlinkpicture

The problem is that the SharePoint Connector does not work when this “Picture” option is set up. This is an old bug that I’ve reported in 2016!. Indeed here is what you get  (we don’t see the picture field) :

flowpictures2

 

When you have such issue in low & SharePoint, you must rely on the Send an HTTP Request to SharePoint, which is one of the “Joker” Flow action (the other one is the HTTP action).

2 issues with this HTTP Request to SharePoint

  1. you need to know the SharePoint REST API
  2. you need to know how to update items in this specific case (which is what I will illustrate here).

 

  • In a SharePoint site, create a custom list, with 2 additional columns:
    • temperature (single line of text)
    • picture : hyperlink with the option format as picture
  • Go to the site apixu.com and sign-up for a free account; you will get a key that you will use in Flow
  • So create a flow and use the Recurrence trigger (set the interval to 1 hour).
  • Add a SharePoint – Get items action that fetch through your list
  • Add an Apply to each
  • in the Apply to each add an HTTP action
  • In the HTTP action, select the Get method, and the uri should be:

Http

the output of this HTTP action looks like this

{
  “location”: {
    “name”“Namur”,
    “region”“”,
    “country”“Belgium”,
    “lat”50.47,
    “lon”4.87,
    “tz_id”“Europe/Brussels”,
    “localtime_epoch”1533214214,
    “localtime”“2018-08-02 14:50”
  },
  “current”: {
    “last_updated_epoch”1533213033,
    “last_updated”“2018-08-02 14:30”,
    temp_c29,
    “temp_f”84.2,
    “is_day”1,
    “condition”: {
      “text”“Partly cloudy”,
      “icon”//cdn.apixu.com/weather/64×64/day/116.png”,
      “code”1003
    },
    “wind_mph”5.6,
    “wind_kph”9,
    “wind_degree”340,
    “wind_dir”“NNW”,
    “pressure_mb”1023,
    “pressure_in”30.7,
    “precip_mm”0,
    “precip_in”0,
    “humidity”40,
    “cloud”25,
    “feelslike_c”28.9,
    “feelslike_f”84.1,
    “vis_km”10,
    “vis_miles”6
  }
}

  • Add a data operation Compose action and name it Temperature
  • In its expression textbox type:  body(‘HTTP’]?[‘current’]?[‘temp_C’]
  • Add another data operation Compose action and name it weatherUrl
  • its expression should be : concat(‘http:’,body(‘HTTP’)[‘current’]?[‘condition’]?[‘icon’])
  • Add a Send an HTTP request to SharePoint action
  • The settings of this action must be : (don’t forget the set the method to POST)

sentosp

  • Your flow should look like this:

flowfinal

  • Run and test your flow :

final

Now if you want to have fun, you can display this list in a web part or even better create a PowerApps that will show up in a web part.

Happy flow-ing !

 

 

 

 

 

 

 

 

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s