I’m trying to upload an image to a specific SharePoint list using the Microsoft Graph REST API v1.0, but I’m having a hard time understanding how to do it correctly. I’ve been looking for documentation and examples, but haven’t found a clear solution yet.
How to upload an image to a sharepoint “LIST” using Graph?
In my case I already managed to upload a file to a folder as a document by converting the
image to an array of bytes.
It was really easy to upload images to a document library in SharePoint.
BUT The idea is to upload the image to a LIST and it is required that it be an image type, I don’t know what you expect the API to send there.
A SharePoint list item is a row of data in a SharePoint list, which is a collection of information organized into rows and columns.
I have tried several methods in the documentation without obtaining any results.
graphClient.Sites[siteId].Lists[listId].Items[itemId].Fields.Request().UpdateAsync(fieldsToUpdate);
graphClient.Sites[siteId].Lists[listId].Items[itemId].Fields.Request().CreateAsync(fieldsToUpdate);
graphClient.Sites[siteId].Lists[listId].Items.Request().AddAsync(ListItem);
In the documentation there are no examples of mounting an image:
https://learn.microsoft.com/en-us/graph/api/listitem-create?view=graph-rest-1.0&tabs=csharp
They create a JSON but send only plain text.
I have also sent the address of the image but I get an error.
THIS IS MY CODE:
My method that uploads to a folder does it fine.
enter image description here
but I haven’t had any luck with this one on the list:
enter image description here
arley suarez agudelo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.