Microsoft Flow - Update a Hyperlink or Picture field 1

Microsoft Flow – Update a Hyperlink or Picture field

When you use flow to update list items it is  quite easy to update test fields, however one of the issues I ran into today was to update a picture column.

As part of my flow that collects the updates for the available Microsoft Flow connectors, I’m creating list items.

Images shown in a SharePoint list

 

Unfortunately the Update item or Create Item actions do not show the picture columns. I managed to create a text field but that will just show up as the url of the hyperlink. I my case I want the icons to appear instead.

Update a Url field

As so often the Send HTTP request to SharePoint comes to the rescue.

Update a Url field with a Send an HTTP request to SharePoint

29 thoughts on “Microsoft Flow – Update a Hyperlink or Picture field

  1. Hi,

    Would you be able to explain more how you achieve this?

    I’m working on a project that requires updating a sharepoint list picture column data from Powerapps or Microsoft Flow. We are using SPO O365.

  2. This is exactly what I was looking for. I do not know much JSON and I get an error “Not well formatted JSON stream.”

    I am typing in the Body section of the HTTP action exactly as was posted on this page. What am I missing or doing wrong?

    In the flow history log it shows this HTTP call:

    {‘__metadata’:{‘type’:’SP.Data.ConnectorsListItem’}.’Icon’:
    { ‘Description’: ‘Icon’,
    ‘Url’: ‘(here it shows PNG non-text output)’
    }
    }

    Do I have to change “icon” to the name of one of my columns?

  3. Okay, I sent you some screenshots. I fixed the first error but encountered another.

    The ‘not well formatted JSON’ error was probably caused by the Headers not being correct. In your screen shot, there was not a line between 2 of the headers, butit seems that there should be.

  4. I have an attachment column contains a url of an image. (this has been created by the attachment control of powerapps) and I want to update the picture type column with the url in the attachment. how can this be done?

  5. I fixed my original ‘not well formatted JSON’ error by fixing the headers (there should be lines in between, even though they do not appear in the screenshots), but encountered another problem. The new error is, “A type named ‘SP.Data.ConnectorsListItem’ could not be resolved by the model. When a model is available, each type name must resolve to a valid type.”

    To simplify the testing, I removed the addition of the icon and focused only on updating the Summary.

    {‘__metadata’:{‘type’:’SP.Data.ConnectorsListItem’},
    ‘Summary’: “This test worked”
    }

  6. Hello,

    When I try the same in our environment, getting the below error.

    “status”: 400,
    “message”: “Invalid JSON. A comma character ‘,’ was expected in scope ‘Object’. Every two elements in an array and properties of an object must be separated by commas.\r\nclientRequestId: 774470e9-9bd4-493c-916e-a3d6f1f7dcf9\r\nserviceRequestId: 7e70059f-101f-9000-7a74-5933827c0e95”,

    Could you please help me getting this error fixed?

  7. Hi Pieter,

    I’m getting this error message as at below:-
    “message”: “The property ‘__metadata’ does not exist on type ‘SP.Data.Spot_x0020_listListItem’. Make sure to only use property names that are defined by the type.\r\nclientRequestId: ab710f58-0b71-4164-bac3-d92ce48182f3\r\nserviceRequestId: af0c219f-d04b-0000-480e-c2ee97236b5e”,
    “status”: 400″

    Could you please help me to find the root cause?
    I have emailed you the screenshots.

    Thank you.

      1. Hi Lisa,
        It looks like the http request isn’t recognising the verbose mode. Can you check if there is a space or anything else after the ; in the Content-type? A space works and I think that you can even do this without a space there.

      2. Hi Pieter, I have solved my problem. I changes my coding in body as:
        {
        ‘__metadata’: {‘type’:’SP.Data.Spot_x0020_listListItem’},
        ‘QRCodeGenerator’ :
        {
        ‘__metadata’: {‘type’:’SP.FieldUrlValue’},
        ‘Description’: ‘httpxxxxxx’)}’,
        ‘Url’: ‘httpxxxxx’)}’
        }
        }

        And it’s work!

  8. Hi Pieter, you are right! I checked again the Headers from my failed log. it’s my typo error, previously i wrote as “Content_Type” instead of “Content-Type”.

    Thank you very much Pieter. I will keep follow your blog. It’s really help me a lot! Cheers~ 🙂

  9. Hi Pieter,
    Perhaps you could help me with my flow get to work. I collect data with a form in MS Forms. Last question allows users to upload up to 2 images max. 10 MB each. I have my list on sharepoint online which presents items sent within MS Forms. This is all hapenning thanks to flows in Power Automate, which works each time the user clicks “SENT” button in on my form in MS Forms. It is also sends email notification to group of users to let them know something new has appeared in the list. Images are saved on OneDrive in Shared Library.
    Tried to implement your HTTP request to show images sent within a form but I can’t get it work (error 400). So could you look at this piece of code?

    {
    “inputs”: {
    “host”: {
    “connection”: {
    “name”: “@parameters(‘$connections’)[‘shared_sharepointonline_1’][‘connectionId’]”
    }
    },
    “method”: “post”,
    “body”: {
    “method”: “POST”,
    “uri”: “/_api/web/lists/getbytitle(‘GIEŁDA TOWARÓW HANDLOWYCH’)/Items(@{body(‘Utwórz_element’)?[‘ID’]})”,
    “headers”: {
    “accept”: “application/json;odata=verbose”,
    “content-type”: “application/json;odata=verbose”,
    “X-HTTP-Method”: “MERGE”,
    “If-Match”: “*”,
    “X-RequestDigest”: “__yourRequestDigest__”
    },
    “body”: “{\n‘__metadata’: {‘type’:’SP.Data.GIEŁDA TOWARÓW HANDLOWYCH_ListItem’},‘Zdjęcia_oferowanego_towaru’\n{\n‘Description’: ‘Zdjęcia_oferowanego_towaru’,\n‘Url’: ‘@{body(‘Pobierz_szczegóły_odpowiedzi’)?[‘r23a254dd77ae4c8c958cda3473ae2fac’]}’\n}\n}”
    },
    “path”: “/datasets/@{encodeURIComponent(encodeURIComponent(‘https://pocztapolska.sharepoint.com/sites/GIEDATOWARWHANDLOWYCH’))}/httprequest”,
    “authentication”: “@parameters(‘$authentication’)”
    },
    “metadata”: {
    “flowSystemMetadata”: {
    “swaggerOperationId”: “HttpRequest”
    }
    }
    }

    If there would be a problem with getting this work I could accept showing an URL in my list column, which would lead to apriopriate image and show it in a browser after clicking.
    Thanks a lot in advance.

    1. Hi Marcin,

      It’s difficult to identify the issue from code, but it looks like something might be wrong in the body of the http request

      In the following bit there are some spaces.
      ‘type’:’SP.Data.GIEŁDA TOWARÓW HANDLOWYCH_ListItem’

      In your browser can you go to

      https://pocztapolska.sharepoint.com/sites/GIEDATOWARWHANDLOWYCH/_api/web/lists/getbytitle(‘GIEŁDA TOWARÓW HANDLOWYCH’)/Items

      You should then get data returned this will include the type (just search for SP.Data)

  10. Thanks for quick reply.

    Correct URL I can go to is https://pocztapolska.sharepoint.com/sites/GIEDATOWARWHANDLOWYCH/_api/web/lists/getbytitle('GIE%C5%81DA%20TOWAR%C3%93W%20HANDLOWYCH‘)/Items (without spaces). There I learned SP.Data should be SP.Data.GIEDA_x0020_TOWARW_x0020_HANDLOWYCHListItem so corrected that.

    Made some changes in my code and still getting error 400 with info:
    “Invalid JSON. The property name ” is not valid. The name of a property cannot be empty.\r\nclientRequestId: 6087d5cc-a300-4093-b3bf-012c1d17b78d\r\nserviceRequestId: 4fb7349f-a082-9000-c98d-9a2aa4d1e8b0″
    Now my body section of the flow looks like this:

    {
    ‘__metadata’: {‘type’:’SP.Data.GIEDA_x0020_TOWARW_x0020_HANDLOWYCHListItem’},‘Zdj_x0019_cia_z0020_oferowanego_x0020_towaru’
    {
    ‘Description’: ‘Zdj_x0019_cia_x0020_oferowanego_x0020_towaru’,
    ‘Url’: ‘@{body(‘Pobierz_szczegóły_odpowiedzi’)?[‘r23a254dd77ae4c8c958cda3473ae2fac’]}’
    }
    }

    I’m not sure if I understand it right but my list column, where I want an image to appear is “Zdj_x0019_cia_z0020_oferowanego_x0020_towaru” or in my language “Zdjęcia oferowanego towaru”. Column name in your example above is “Icon”. Is it included in code?

    Regards,
    Marcin

    1. Hi Marcin,

      There is a : missing just after the field name.

      {
      ‘__metadata’: {‘type’:’SP.Data.GIEDA_x0020_TOWARW_x0020_HANDLOWYCHListItem’},‘Zdj_x0019_cia_z0020_oferowanego_x0020_towaru’:
      {
      ‘Description’: ‘Zdj_x0019_cia_x0020_oferowanego_x0020_towaru’,
      ‘Url’: ‘@{body(‘Pobierz_szczegóły_odpowiedzi’)?[‘r23a254dd77ae4c8c958cda3473ae2fac’]}’
      }
      }

      Also the Description is the text that you want to use to display on the link, so this can be any text.

      I would probably check if @{body(‘Pobierz_szczegóły_odpowiedzi’)?[‘r23a254dd77ae4c8c958cda3473ae2fac’]} has got a valid value by putting it into Compose action.

  11. Added : in the place you’ve suggested but still got the same error.
    URL in body (‘Pobierz_szczegóły_odpowiedzi’) is “[{\”name\”:\”kosz4_Marcin Fiedorowicz.jpg\”,\”link\”:\”https://pocztapolska-my.sharepoint.com/personal/marcin_fiedorowicz_poczta-polska_pl/Documents/Apps/Microsoft%20Forms/GIE%C5%81DA%20TOWAR%C3%93W%20HANDLOWYCH/Pytanie/kosz4_Marcin%20Fiedorowicz.jpg\”,\”id\”:\”01QETLXRFOYBVVT7FPBZC3G4DWVSC73XIY\”,\”type\”:null,\”size\”:32413,\”referenceId\”:\”01QETLXRGU5LXB5ZXPDNGZZHWVQAC4BZZG\”,\”driveId\”:\”b!B7Ux9Ul7e0SQtT3wM7XuPkKbxZkypiRCh5ABQYm1c3Ac0gAbIWwAT4OsmSUOpC5c\”,\”status\”:1,\”uploadSessionUrl\”:null}]”

    In my code at the end I use MS Forms field name “Zdjęcia oferowanego towaru” as Url – it even has a MS Forms small icon. You use “ConnectorIcon” with Power Automate small icon. Does it matter?

    Regards,

  12. Found your article about common errors with explanations. So I followed your favourite one and corrected quotas. Now I got the same error number [400] but with this info:
    “The property ‘Zdj_x0119_cia_x0020_oferowanego’ does not exist on type ‘SP.Data.GIEDA_x0020_TOWARW_x0020_HANDLOWYCHListItem’. Make sure to only use property names that are defined by the type.\r\nclientRequestId: 74baf299-545d-4924-abce-5cefb8f2b49f\r\nserviceRequestId: 9bfb349f-80db-9000-5be0-3439e6cc747c”
    Does it mean I put column name incorrectly?

    Regards,

  13. Another update:
    Found apriopriate column name and corrected it in my code. After test i got error 400 info:
    “Invalid URL: [{\”name\”:\”1_Marcin Fiedorowicz.jpg\”,\”link\”:\”https://pocztapolska-my.sharepoint.com/personal/marcin_fiedorowicz_poczta-polska_pl/Documents/Apps/Microsoft%20Forms/GIE%C5%81DA%20TOWAR%C3%93W%20HANDLOWYCH/Pytanie/1_Marcin%20Fiedorowicz.jpg\”,\”id\”:\”01QETLXRHL54TQIKCG3FALTHRFMMUJW6EL\”,\”type\”:null,\”size\”:161179,\”referenceId\”:\”01QETLXRGU5LXB5ZXPDNGZZHWVQAC4BZZG\”,\”driveId\”:\”b!B7Ux9Ul7e0SQtT3wM7XuPkKbxZkypiRCh5ABQYm1c3Ac0gAbIWwAT4OsmSUOpC5c\”,\”status\”:1,\”uploadSessionUrl\”:null}].\r\nclientRequestId: fb11076a-93c5-438b-af76-8e62e580bb54\r\nserviceRequestId: 60fc349f-20cf-9000-de86-24b3f4090737″,
    Have no idea of the reason for that. But I feel I’m getting closer to success. Any hints?

    Regards,

  14. I’d like to but can’t paste images to Reply field (or I don’t know how). If you could email me on my address I put every time I post something here and I’d reply on this with screenshots.

  15. Hi,

    I am facing issue while updating option field value in list item. Formatting body as below works good for me with text columns:
    {‘__metadata’:{‘type’:’SP.Data.Application_x0020_RequestListItem’},’EditLOCK’:Yes}

    but above field being option(dropdown) field, I have tried several ways to modify above body text but nothing seems to work. On passing Yes in double/single quotes, boolean exception is thrown:
    Invalid JSON. A token was not recognized in the JSON content.

    1. Hi,

      The easiest way to get the format of the EditLock field right is by collecting the data from an existing item. You can do this by running a flow and rather than POST do a GET on the same URL with an empty Body configured on the action. Alternatively just copy the full url into a browser and this will get you the data for existing items, giving you the format of the data required.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: