-
Notifications
You must be signed in to change notification settings - Fork 263
Description
Describe the bug
Hi,
Graph SDK: NuGet "Microsoft.Graph" Version="5.73.0"
C# (dotnet 8)
I`m getting 'System.Text.Json.JsonReaderException' exception.
This exception is not being thrown consistently.
This is a snipped code of the Graph SDK useage:
GraphClient
.Users[mUser.Id]
.MailFolders[iFolder.Id]
.Messages
.GetAsync(iConfig => {
iConfig.QueryParameters.Select = [
"from",
"receivedDateTime",
"createdDateTime",
"subject",
"id",
"hasAttachments",
"body",
"attachments"
];
iConfig.QueryParameters.Expand = ["attachments"];
iConfig.QueryParameters.Filter = iFilter;
iConfig.QueryParameters.Orderby = ["receivedDateTime DESC"];
iConfig.QueryParameters.Top = rOffice365Settings.MailsCountToRead;
iConfig.Headers.Add("Prefer", $"outlook.body-content-type=\"{rOffice365Settings.PreferredContentType}\"");
iConfig.Headers.Add("Accept-Language", rOffice365Settings.AcceptLanguage);
},
cancellationToken: iCancellationToken).ConfigureAwait(false);The mail box language is in Espanol (Costa Rica) so I tried to play with the settings but it did not helped.
- Reduce mails fetch count.
- Changed AcceptLanguage for both English and Spanish.
When:
AcceptLanguage: en-US,
PreferredContentType: text,
mailsCountToReadPerIteration: 10
I got:
Error from System.Text.Json: System.Text.Json.JsonReaderException: 'e' is invalid after a value. Expected either ',', '}', or ']'. LineNumber: 0 | BytePositionInLine: 7464595. at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan1 bytes)
at System.Text.Json.Utf8JsonReader.ConsumeNextToken(Byte marker)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.JsonDocument.Parse(ReadOnlySpan1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack) at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter)
at System.Text.Json.JsonDocument.ParseAsyncCore(Stream utf8Json, JsonDocumentOptions options, CancellationToken cancellationToken)
at Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory.GetRootParseNodeAsync(String contentType, Stream content, CancellationToken cancellationToken)
at Microsoft.Kiota.Abstractions.Serialization.ParseNodeProxyFactory.GetRootParseNodeAsync(String contentType, Stream content, CancellationToken cancellationToken)
at Microsoft.Kiota.Abstractions.Serialization.ParseNodeFactoryRegistry.GetRootParseNodeAsync(String contentType, Stream content, CancellationToken cancellationToken)
at Microsoft.Kiota.Abstractions.Serialization.ParseNodeProxyFactory.GetRootParseNodeAsync(String contentType, Stream content, CancellationToken cancellationToken)
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.GetRootParseNodeAsync(HttpResponseMessage response, CancellationToken cancellationToken)
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory1 factory, Dictionary2 errorMapping, CancellationToken cancellationToken)
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory1 factory, Dictionary2 errorMapping, CancellationToken cancellationToken)
at Microsoft.Graph.Users.Item.MailFolders.Item.Messages.MessagesRequestBuilder.GetAsync(Action1 requestConfiguration, CancellationToken cancellationToken)
When:
AcceptLanguage: es-ES
PreferredContentType: text
MailsCountToRead: 10
I got:
Error from System.Text.Json: System.Text.Json.JsonReaderException: Expected depth to be zero at the end of the JSON payload. There is an open JSON object or array that should be closed. LineNumber: 0 | BytePositionInLine: 361.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.ReadSingleSegment()
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.JsonDocument.Parse(ReadOnlySpan`1 utf8JsonSpan, JsonReaderOptions readerOptions, MetadataDb& database, StackRowStack& stack)
at System.Text.Json.JsonDocument.Parse(ReadOnlyMemory`1 utf8Json, JsonReaderOptions readerOptions, Byte[] extraRentedArrayPoolBytes, PooledByteBufferWriter extraPooledByteBufferWriter)
at System.Text.Json.JsonDocument.ParseAsyncCore(Stream utf8Json, JsonDocumentOptions options, CancellationToken cancellationToken)
at Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory.GetRootParseNodeAsync(String contentType, Stream content, CancellationToken cancellationToken)
at Microsoft.Kiota.Abstractions.Serialization.ParseNodeProxyFactory.GetRootParseNodeAsync(String contentType, Stream content, CancellationToken cancellationToken)
at Microsoft.Kiota.Abstractions.Serialization.ParseNodeFactoryRegistry.GetRootParseNodeAsync(String contentType, Stream content, CancellationToken cancellationToken)
at Microsoft.Kiota.Abstractions.Serialization.ParseNodeProxyFactory.GetRootParseNodeAsync(String contentType, Stream content, CancellationToken cancellationToken)
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.GetRootParseNodeAsync(HttpResponseMessage response, CancellationToken cancellationToken)
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory`1 factory, Dictionary`2 errorMapping, CancellationToken cancellationToken)
at Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.SendAsync[ModelType](RequestInformation requestInfo, ParsableFactory`1 factory, Dictionary`2 errorMapping, CancellationToken cancellationToken)
at Microsoft.Graph.Users.Item.MailFolders.Item.Messages.MessagesRequestBuilder.GetAsync(Action`1 requestConfiguration, CancellationToken cancellationToken)
Please advice how to continue.
Expected behavior
Enable to read emails
How to reproduce
I`m not sure but maybe set the mailbox language to Spanish
SDK Version
5.73.0
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```</details>
### Configuration
_No response_
### Other information
_No response_