Use Flow to Update SharePoint Hyperlink Field

If you want to update a hyperlink field in SharePoint Online using Flow, you will need to use the Send an HTTP request to SharePoint action (for now). I first tried using the Update item Flow action, but it would not correctly set the URL and Description values. Another issue I had was using the Post method instead of Patch. Every blog/forum post was suggesting the use of the Post method, but the Patch method is what I ended up using.

For testing, create a list titled Contractors. In the list, add a Hyperlink field titled website. In your Flow, add a Send HTTP request to SharePoint action.

Site Address: select the site you created the Contractors list in.
Method: PATCH
Uri: _api/web/lists/getbytitle(‘Contractors’)/Items(‘ID From above Action’)
Headers
Accept application/json
Content-Type application/json; odata=verbose
X-HTTP-TYPE MERGE
IF-MATCH *
Body

{
'__metadata': { 'type': 'SP.Data.ContractorsListItem' },
   'website':
   {
          '__metadata': {'type':'SP.FieldUrlValue'},
               'Description':'Title from above Action',
                'Url': 'http://www.bbb.com'
  }
}

Peek code:

{
    "inputs": {
        "host": {
            "connection": {
                "name": "@parameters('$connections')['shared_sharepointonline']['connectionId']"
            }
        },
        "method": "post",
        "body": {
            "method": "PATCH",
            "uri": "_api/web/lists/getbytitle('Contractors')/Items('@{triggerBody()?['ID']}')",
            "headers": {
                "Accept": "application/json",
                "Content-Type": "application/json; odata=verbose",
                "X-HTTP-TYPE": "MERGE",
                "IF-MATCH": "*"
            },
            "body": "{\n'__metadata': { 'type': 'SP.Data.ContractorsListItem' },\n   'website':\n   {\n          '__metadata': {'type':'SP.FieldUrlValue'},\n               'Description':'@{triggerBody()?['Title']}',\n                'Url': 'http://www.bbb.com'\n  }\n}"
        },
        "path": "/datasets/@{encodeURIComponent(encodeURIComponent('https://EnterYourURL.sharepoint.com/sites/spdev'))}/httprequest",
        "authentication": "@parameters('$authentication')"
    },
    "metadata": {
        "flowSystemMetadata": {
            "swaggerOperationId": "HttpRequest"
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *