invest-openapi-csharp-sdk
invest-openapi-csharp-sdk copied to clipboard
Пустой Response на примере из readme (Tinkoff.Trading.OpenApi.Network.OpenApiInvalidResponseException)
Аналог #46, которое закрыто и, видимо, последующий ответ (пятидневной давности) никто не увидел.
Пример из readme:
using Tinkoff.Trading.OpenApi.Network;
var token = File.ReadAllText("mypath");
var connection = ConnectionFactory.GetConnection(token);
var context = connection.Context;
var portfolio = await context.PortfolioAsync();
foreach (var position in portfolio.Positions)
{
Console.WriteLine(position.Figi);
}
Падает в PortfolioAsync()
:
Unhandled exception. Tinkoff.Trading.OpenApi.Network.OpenApiInvalidResponseException: Unable to handle response.
Response:
Продолжение stack trace
---> System.Text.Json.JsonException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. Path: $ | LineNumber: 0 | BytePositionInLine: 0.
---> System.Text.Json.JsonReaderException: The input does not contain any JSON tokens. Expected the input to start with a valid JSON token, when isFinalBlock is true. LineNumber: 0 | BytePositionInLine: 0.
at System.Text.Json.ThrowHelper.ThrowJsonReaderException(Utf8JsonReader& json, ExceptionResource resource, Byte nextByte, ReadOnlySpan`1 bytes)
at System.Text.Json.Utf8JsonReader.Read()
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, JsonReaderException ex)
at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadFromSpan[TValue](ReadOnlySpan`1 utf8Json, JsonTypeInfo jsonTypeInfo, Nullable`1 actualByteCount)
at System.Text.Json.JsonSerializer.Deserialize[TValue](ReadOnlySpan`1 utf8Json, JsonSerializerOptions options)
at Tinkoff.Trading.OpenApi.Network.Connection`1.HandleResponseAsync[TOut](HttpResponseMessage response)
--- End of inner exception stack trace ---
at Tinkoff.Trading.OpenApi.Network.Connection`1.HandleResponseAsync[TOut](HttpResponseMessage response)
at Tinkoff.Trading.OpenApi.Network.Connection`1.SendGetRequestAsync[TPayload](String path)
at Tinkoff.Trading.OpenApi.Network.Context.PortfolioAsync(String brokerAccountId)
at Program.<Main>$(String[] args) in D:\main\trading\TradingAnalysis\TestCSharpDataDownload\TinkoffAPITest\Program.cs:line 9
at Program.<Main>(String[] args)
Версия 1.7.5
Где и какой response мы получаем:
Временный фикс - токен полного доступа, см.