azure-logic-apps

Azure Logic App - Update o365 profile image


I am starting out with Logic Apps and having trouble passing an image to a HTTP PUT to update a users image. Hoping I have missed the obvious. I get the image from a Sharepoint list that our HR upload. I then just want to post to the users o365 account but getting an error "Write requests (excluding DELETE) must contain the Content-Type header declaration." Get Image

Then using HTTP to update image. Thinking the issue may be with the 'File Content' not being the right type and I need to convert to binary or something.

enter image description here


Solution

  • To put profile picture use below design:

    Firstly get the file content :

    enter image description here

    Then use PUT method and below rest api:

    https://graph.microsoft.com/v1.0/users/bojja@bb.com/photo/$value
    

    Give Authorization and Content type:

    Bearer token. You need get the access token and it should have all the permissions to change the picture enter image description here

    To change to binary :

    binary(body('Get_file_content_using_path'))
    

    Place the above expression in Expression section:

    enter image description here

    Or simply paste this @{binary(body('Get_file_content_using_path'))} in body :

    enter image description here

    Output:

    enter image description here

    For generating access token using client credential flow refer this SO-Thread, make sure to grant User.ReadWrite.All of application permission type.