Need a special offer?Find out if your project fits.
+

Implementing the API controller

Answered
Eric Morgan asked on January 26, 2023

Hi,

According to this doc: https://www.flexmonster.com/doc/implementing-api-controller/#step-8-handle-the-select-request

I created the same api controller action like following:

[HttpPost("select")]
public Task<SelectResponse> PostSelectAsync(SelectRequest request)
{
return _fmApiService.GetAggregatedDataAsync(request);
}

I am getting data successfully. For the first loading, here is the client request body:

{
"type":"select",
"index":"1e0f561c-8c16-4254-ca61-3a08cefa570a",
"query":{
"aggs":{
"by":{
"rows":[
{
"uniqueName":"AccomodatedDays"
}
]
},
"values":[
{
"func":"sum",
"field":{
"uniqueName":"GivenCA16"
}
}
]
}
},
"querytype":"select",
"page":0
}

But when I double click to any cell, or filter grid, here is the request body:

{
"type": "select",
"index": "1e0f561c-8c16-4254-ca61-3a08cefa570a",
"query": {
"limit": 1000,
"filter": {
"type": "and",
"value": [
{
"field": {
"uniqueName": "AccomodatedDays"
},
"include": [
{
"member": 0
}
]
}
]
},
"fields": [
{
"uniqueName": "AccomodatedDays"
},
{
"uniqueName": "AccessionNumber"
},
{
"uniqueName": "GivenCA16"
}
]
},
"page": 0
}

As you can see there is a filter property in the request body. filter.value.field and filter.value.include is not matching the model (SelectRequest). SelectRequest model is not contains these properties. So asp.net core api is returning HTTP 400 error if filter property is not null, because request-body and model is not matching.

 

5 answers

Public
Eric Morgan January 26, 2023

Summary: we can not deserialize request-body to SelectRequest.

Public
Maksym Diachenko Maksym Diachenko Flexmonster January 27, 2023

Hello, Patrick!

Thank you for your question.

We could not reproduce this issue on our GitHub example server with the /select drill-through request having the same structure. The FDS DLL filter model uses the LogicFilter and BaseFilter classes. Both of these filter classes use different JSON converters, [JsonConverter(typeof(LogicFilterJsonConverter))] and [JsonConverter(typeof(BaseFilterJsonConverter))] correspondingly to parse the request filters. The converters use the System.Text.Json for deserialization. After the deserialization, each FilterObject of request is converted to Filter class, containing all available filter types.

Our recommendation is to check if any settings that may change the serializer from System.Text.Json are present in your project. If so, try to remove them and see if this helps to fix the issue. 

Please let us know if our reply was helpful in finding the cause of this issue.

Best Regards,
Maksym

Public
Eric Morgan February 3, 2023

We are using dotnet7, can this related to this?

Public
Eric Morgan February 3, 2023

Ok, I fixed this by custom deserializer.

Public
Maksym Diachenko Maksym Diachenko Flexmonster February 6, 2023

Hello, Patrick!

Thank you for your reply.
We are glad to hear that you solved the issue by using the custom deserializer. Answering your previous question, it is unlikely that .NET 7 caused this issue since it is backward compatible with previous versions.
Please let us know if any other questions arise.

Best Regards,
Maksym

Please login or Register to Submit Answer