Search code examples
microsoft-graph-apionedrive

How can i get a files Id on Onedrive using the graph api?


I have a file that i know exists in one drive , TestFile.xlxs.It sits in the folder Folder1/SubFolder2/SubFolder 2a/. I am trying t get the fileId as follows, so i can move the file to another folder in OneDrive

https://graph.microsoft.com/v1.0/me/drive/root:/Folder1/SubFolder2/SubFolder 2a/TestFile.xlsx

but i get the error

    "code": "BadRequest",
    "message": "Empty Payload. JSON content expected.",

Any ideas how i can get the id of the file ?


Solution

  • Looks like you did POST request instead of GET.

    GET https://graph.microsoft.com/v1.0/me/drive/root:/Folder1/SubFolder2/SubFolder 2a/TestFile.xlsx
    

    POST request will probably work if you add empty json into the request body.

    {}