Windows Form App - SharePoint Image Upload
Hello everyone,
I'm currently working on a Windows Form application using C# and have encountered an issue with uploading images to SharePoint. The objective is to allow users to upload images through the Windows Form, and I want these images to be reflected in a SharePoint table.
Here's a quick overview of my process:
1. Users upload images through the Windows Form app.
2. The app uploads images to SharePoint's siteassets.
3. The corresponding SharePoint table gets updated with image information.
The challenge I'm facing is that while the images successfully upload to SharePoint's siteassets, they don't appear in the SharePoint table.
Bellow is a snippet of code:
1 Reply
I've gone ahead and attepted using the following method:
I used the following as a reference (https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/upload-a-file-by-using-the-rest-api-and-jquery#running-the-code-examples, https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/determine-sharepoint-rest-service-endpoint-uris?tabs=csom) and with this I unfortunately hit a permission wall. I am able to add all my other fields when creating rows. To my understanding the code above is updating and editing instead of adding.
Any way I can adjust this or get alternative methods to solving the issue without changing the permissions. Do not want this part of the code editing
Managed to solve the issue:
You have to use a JSON format when uploading the image. First make sure you upload image to sharepoint itself (if you need that code message me), then after that, all you do is create a JSON with the following format:
Then when adding you put the variable in:
Then you should be good. I hope this helps someone else and saves time...took me 5 days to figure this out
Thats how you add an image to an item that has an 'image' type