Hi @Robin GANTNER,
Thank you for posting in this community.
Q1: Is it possible to insert metadata when uploading a file with API graph?
Unfortunately, we can't add metadata at the same time as uploading the file. We need to make two requests, one to upload the file and one to update the file's metadata.
Q2: What is the purpose of the id returned by the first PUT to upload the files? Is it possible to use it to set my columns?
According to the document put request, part of the information about the driveItem object is returned. where id refers to "The unique identifier of the item within the Drive.". It is different from listId.
Q3: Is it possible to get the id that permit me to set the columns other than by this query string?
We can use siteId, listId, itemId to get the file you uploaded and update the metadata of the file.
Reference: Update listItem.
We can also make the above requests in bulk:
Here’s a simplified example of how you might structure a batch request to update metadata for multiple files:
POST https://graph.microsoft.com/v1.0/$batch
Content-Type: application/json
{
"requests": [
{
"id": "1",
"method": "PATCH",
"url": "
"headers": {
"Content-Type": "application/json"
},
"body": {
"name": "new-file-name-1.docx",
"description": "Updated description for file 1"
}
},
{
"id": "2",
"method": "PATCH",
"url": "
"headers": {
"Content-Type": "application/json"
},
"body": {
"name": "new-file-name-2.docx",
"description": "Updated description for file 2"
}
}
// Add more requests as needed
]
}
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.