Missing "WebDavUrl" from GetDriveItem API

Viewed 14

I am trying to retrieve WebDavUrl along with the rest of the data. I am using the below approach

 public DriveItem getDriveItemWebDavUrl(String driveId, String itemId) {
    return graphClient.drives(driveId)
            .items(itemId)
            .buildRequest()
            .select("*,webDavUrl")
            .get();
}

and I can see below url generated by graph API

https://graph.microsoft.com/v1.0/drives/{driveId}/items/{itemId}?select=*%2CwebDavUrl

But the Graph API does not return webDavUrl along with the response. When I use the same URL in GraphExplorer it works as expected.

I'll appreciate any suggestions or feedback

1 Answers

I have found the solution, If we use QueryOption then it works like charm.

 public DriveItem getDriveItemWebDavUrl(String driveId, String itemId) {
      return graphClient.drives(driveId)
        .items(itemId)
        .buildRequest(List.of(new QueryOption("select", "*,webDavUrl")))
        .get();}
Related