microsoft-graph-apionedrivemicrosoft-graph-filesmicrosoft-graph-sites

Access OneDrive file with .svc extension using Microsoft graph API


We have to access several OneDrive files using Microsoft graph API. This works well until we met some file whose name ends with .svc (they are regular files).

We have a request that looks like: https://graph.microsoft.com/v1.0/users/account@xxx.onmicrosoft.com/drive/root:/file.svc

And it fails with a 400 Bad request (all other requests succeed).

We have tried the following, without success:

How to encode a file name with a .svc extension so graph API accepts it? (There is a way for sure, since we managed to upload such a file)


Solution

  • To access file content itself, the URI had to be https://graph.microsoft.com/v1.0/users/account@xxx.onmicrosoft.com/drive/root:/file.svc:/content (the :/content at the end does the trick, because it is semantically correct).