Most SharePoint developers frequently face a requirement to convert a SharePoint List Item into File Object and a File Object into List Item.
In the modern technology world, Microsoft Graph API comes with a name of unified API development model for accessing all the services across the Microsoft Cloud. Hence, Microsoft Graph also comes with the converting endpoints of List Item into the file and vice-versa.
Convert File Object into SharePoint List Item
Format
https://graph.microsoft.com/v1.0/sites/root/drives/{drive-id}/list/items/{item-id}
drive-id => Id of the Document Library / Folder
item-id => Item Id of the folder
Example
https://graph.microsoft.com/v1.0/sites/root/drives/b!ODjN7qUxPU-9TdItTXITu2l03od4f6FPteQYQ3-WZMsqHNVFZWLmT65vzttLdpDe/list/items/10
Convert List Item to File
Format
https://graph.microsoft.com/beta/sites/root/lists/{list-id}/items/{item-id}/driveitem
list-id => SharePoint List ID
item-id => Item Id from the List. If the List Item is not a file, it returns the error response.
Example
https://graph.microsoft.com/beta/sites/root/lists/45d51c2a-6265-4fe6-ae6f-cedb4b7690de/items/10/driveitem