So I have a document library at https://tenant.sharepoint.com/sites/Test/Documents/
and I have a document in it called Doc1.docx. It has an Item Id of 1.
I use the following rest call in a browser to get the id of the list item associated with the document
https://tenant.sharepoint.com/sites/Test/_api/web/getFileByServerRelativeUrl('/sites/Test/Documents/Doc1.docx')/listItemAllFields?$select=Id,Title
As expected it comes back with the proper list item id of one.
Now I go and delete Doc1.docx from the library, and then upload it again. Now the Doc1.docx has the item Id of 2, right?
I use the same rest call to get the Id of the list item associated with the document
https://tenant.sharepoint.com/sites/Test/_api/web/getFileByServerRelativeUrl('/sites/Test/Documents/Doc1.docx')/listItemAllFields?$select=Id,Title
It still says the list Item ID is still one.
As a workaround I ended up including the 'Modified' field in the $select parameter. This makes it return the proper results.
Update : this workaraound stopped working. Now I got it working by leaving off the # select.
Also note that I am generating these rest calls with-pnp-js-core. Not that that should male any difference:
return pnp.sp.web.getFileByServerRelativeUrl(results.data.ServerRelativeUrl).getItem<{ Id: number, Title: string, Modified: Date }>("Id", "Title", "Modified").then((item) => {
Is this the expected behaviour of getFileByServerRelativeUrl or is this a bug?