Nelson Nyland
Nelson Nyland

Reputation: 555

Why am I getting a NotSupportedException when I call the Graph API?

After calling the Microsoft Graph API using a call like this:

var driveItem = await _graphApiClient.Sites[SiteId].Drives[DriveId].Root.ItemWithPath(path)
    .Request().GetAsync();

I get:

System.NotSupportedException: Serialization and deserialization of 'System.Action' instances are not supported. Path: $.MoveNextAction.
 ---> System.NotSupportedException: Serialization and deserialization of 'System.Action' instances are not supported.
   at System.Text.Json.Serialization.Converters.UnsupportedTypeConverter`1.Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
   at System.Text.Json.Serialization.JsonConverter`1.TryWrite(Utf8JsonWriter writer, T& value, JsonSerializerOptions options, WriteStack& state)
   at ...

Upvotes: 4

Views: 4094

Answers (1)

Nelson Nyland
Nelson Nyland

Reputation: 555

Check whether you are calling your method using an await or async handler.

My example:

BEFORE

return Ok(graphManager.GraphMethod(request));

AFTER

return Ok(graphManager.GraphMethod(request).Result);

Upvotes: 12

Related Questions