Good morning.
I have a WebApi "GetByList" method written in NetCore 3.1 and C #.
[HttpPost]
[Route("Data/GetByList")]
public async Task<TagResultList> GetByList([FromBody] Entities.SearchParamsListApiModel searchParamsModel)
{
//some code
}
Input method type:
[ProtoContract]
public class SearchParamsListApiModel : IValidatableObject
{
[ProtoMember(1, Name = "SearchParamses")]
public List<SearchParams> SearchParamses { get; set; }
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
return new SearchParamsListValidatable(SearchParamses).Validate(validationContext);
}
}
Next, I wrote a class to test the call to this method.
public class GetDataPointsTests : WebApiClientTestsBase
{
[Test]
public void SearchParamListWithCorrectDataAndManyRows([Values(880, 881)] int searchParamsCount)
{
var searchParams = new List<SearchParams>();
for (var i = 1; i <= searchParamsCount; i++)
{
searchParams.Add(new SearchParams
{
Tag = $"tag{i}",
StartDateUTC = DateTime.MinValue.ToUniversalTime(),
EndDateUTC = DateTime.UtcNow,
Limit = int.MaxValue
});
}
SignIn();
var result = _webApiClient.GetDataPoints(searchParams);
}
}
The first test (for 880 number of input parameters) is executed without errors, and the second test (for 881) is executed with the following error:
System.InvalidOperationException: Incomplete protobuf payload received; got 0 of 30727 bytes
Q: How do I correct this error?
The LogTraceRequest(context) method was found to be used as follows:
app.Use((context, next) =>
{
LogTraceRequest(context);
//other code
}
and if you comment on this method, the error does not occur. The method was not written by me, so I followed the advice of its author.