GET /drive/items/{item-id}/content?format={format} errors with Not Acceptable - 406

Gal, Ofer (Israel) 131 Reputation points
2024-05-18T09:44:05.4+00:00

Using graph-explorer in my tenant (as general admin) I made sure there is consent for Files.ReadWrite.All

and ran:

https://graph.microsoft.com/v1.0/drives/b!uZmcoKTvYkurWWKXx75Vg1071ukB7H1LjNqAynv0GKBibz5RvZ7ETZ-xW4x2WG52/items/01UYEFCLGSPG6J3F6RPJEKRHPEN5574UIA/content?format={'pdf'}

I get error 406

when using /content?format=pdf I get Bad Request - 400

Same call in C# using Microsoft.Graph" Version="5.50.0"

  var stream = await _graphClient.Drives[driveItem.ParentReference.DriveId].Items[driveItem.Id].Content.GetAsync((requestConfiguration) =>
  {
      requestConfiguration.QueryParameters.Format = "{'pdf'}";
  });

Shows error : System.InvalidOperationException: Content type application/octet-stream does not have a factory registered to be parsed

What Am I missing? is this because my environment is for developers?

Thanks

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,911 questions
0 comments No comments
{count} votes

Accepted answer
  1. awijekoon 1,335 Reputation points Microsoft Vendor
    2024-05-18T19:14:58.5+00:00

    Hello Gal Ofer,

    The correct format is indeed ../content?format=pdf. It seems there might be an issue with the Graph Explorer. However, if you try using a tool like Postman, it should work there.


0 additional answers

Sort by: Most helpful