Using the Sharepoint Online REST API I have successfully created a new file using a POST request -
https://company.sharepoint.com/_api/lists/getbytitle('MyTitle')/Files/add(name='test.jpg',overwrite=true)
Following the documentation I'm now trying to update the file metadata -
If you want to update a file's metadata, you have to construct an endpoint that reaches the file as a list item.
Construct an endpoint that looks like this: https://siteurl/_api/web/lists/getbytitle('Documents')/items(item id)
When creating the file the response I get back from the POST request is something like the following -
{
"d": {
"__metadata": {
"id": "https://company.sharepoint.com/_api/Web/Lists(guid'288441230-b910-4665-ae1d-a359b06c9af8')/files('2_QQs7Rb_UOV1fUNAJw1bJxTMrEZ5qlEmmNfyYNoND5ftgyx2P4lQ4dUdToJAvCF')",
"uri": "https://company.sharepoint.com/_api/Web/Lists(guid'288441230-b910-4665-ae1d-a359b06c9af8')/files('2_QQs7Rb_UOV1fUNAJw1bJxTMrEZ5qlEmmNfyYNoND5ftgyx2P4lQ4dUdToJAvCF')",
"type": "MS.FileServices.File"
}
},
...
}
My question is how do you retrieve the item id
as obviously the urls here are different to the url required by update metadata method.
$expand=ListItemAllFields
parameter to the post request but it doesn't seem to make any difference to the number of fields returned.