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 Security | Microsoft Graph
0 comments No comments
{count} votes

Answer accepted by question author
  1. AsithwMSFT 1,520 Reputation points Microsoft External Staff
    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

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.