Upload thousands of images to SharePoint list's image column using Microsoft Graph C#

Sezgin Tabak 86 Reputation points
2020-12-31T10:57:33.033+00:00

Hi,
I am beginner for development apps for SharePoint and I am not sure that here is a right place to ask my question, so please accept my apologize for any convince. Although, I would like to upload thousands of images from my company's file server (or from my company's local drive) to my company's SharePoint list's image column. However, I read url of images (my company's file server) from a CSV file via CSV Helper(https://joshclose.github.io/CsvHelper/). I can create or update items (example: string, numbers, boolean, hyperlinks etc.) with Microsoft Graph (example: https://learn.microsoft.com/en-us/graph/api/listitem-create?view=graph-rest-1.0&tabs=csharp). Is there a way to upload images (url from csv file) to image column (type of field: image or hyperlink) of SharePoint's list?

Note: I checked (Upload or replace the contents of a DriveItem : https://learn.microsoft.com/en-us/graph/api/driveitem-put-content?view=graph-rest-1.0&tabs=csharp)

Thank you very much for both your time and your consideration.

Happy New Year 2021!

Regards,
Sezgin

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,242 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,804 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jerryzy 10,571 Reputation points
    2021-01-01T06:14:15.237+00:00

    Hi @Sezgin Tabak ,

    If you are using the new image type column like below:

    52603-snipaste-2021-01-01-09-50-05.png

    Then the real value for this column is Json string which looks like this in Graph API:

    52604-snipaste-2021-01-01-09-52-02.png

    {"fileName":"Snipaste_2020-12-31_11-14-29.png","serverRelativeUrl":"/SiteAssets/Lists/a68d0a7d-a523-4ddc-a3a4-d25ca10eb62f/Snipaste_2020-12-31_11-14-29.png","id":"d494712f-8b11-4241-b2a7-fc3025027d2e","serverUrl":"https://zheguo.sharepoint.com","thumbnailRenderer":{"spItemUrl":"https://zheguo.sharepoint.com:443/_api/v2.1/drives/b!nWINb7K58kSmdipZD30IomGUDwTCedpMiv74tZKgtkaHrFmgnp76QI1vFduCaAIJ/items/01GGQFF7JPOGKNIEMLIFBLFJ74GASQE7JO","fileVersion":1,"sponsorToken":"L0xpc3RzL015TGlzdHxkc3wx"}}  
    

    This is hard to hanle this Json string based on a image url and actually the image file is uploaded to the SiteAsserts/lists/updatedlistid sub folder.

    so I suggest you can use normal Hyperlink column instead.

    Thanks
    Best Regards


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Sezgin Tabak 86 Reputation points
    2021-01-01T08:57:21.27+00:00

    Hi @Jerryzy-MSFT ,

    Thank you very much for your answer. I am using the new image type column like above and it is hard to handle Json string, however is it possible to use site asset image URL when I upload all images to site assets folder(Ref Link: https://stackoverflow.com/questions/56151967/post-image-into-list-sharepoint-with-microsoft-graph)? Otherwise I must use Hyperlink column.

    Kind Regards,
    Sezgin


  2. Sezgin Tabak 86 Reputation points
    2021-01-01T15:36:22.977+00:00

    Hi @Jerryzy-MSFT ,

    Thank you very much again and I will use this option.

    I wish you health and great achievements in your career.

    Kind Regards,
    Sezgin Tabak

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.