We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

Error after Applying filter

Open
Peter Mei asked on August 16, 2023

Please see attached file for screenshots of the report and codes. I get error after applying filter on any of the report fields. We use "Referencing the Data Server as a DLL" approach to implement custom data source API. The select API call never reaches server side breakpoint. We use SQL Server database query as index. Please let me know if you need more info.
Error
Custom data source API: request error on 'https://localhost:5001/api/v1/Reports/select'.
[object Object]

The following are the error message from Chome Devtool
query.filter.value[0].field.0: [,…]
"Could not create an instance of type Flexmonster.DataServer.Core.Models.Select.BaseFilter. Type is an interface or abstract class and cannot be instantiated. Path 'query.filter.value[0].field', line 1, position 113."
status: 400
title: "One or more validation errors occurred."
 
custom data source API:
[Route("select")]
[HttpPost]
public IActionResult PostSelect([FromBody] SelectRequest request)
{
var response = _flexmonsterApiService.GetAggregatedData(request);
return new JsonResult(response);
}

11 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster August 17, 2023

Hello, Peter!
 
Thank you for reaching out to us.
 
Could you please let us know if the described filtering behavior is reproducible while following our guide about using the Data Server as a DLL?

We also kindly ask you to try attaching the screenshots and codes one more time. Any additional information would help us greatly to continue the investigation.
 
Looking forward to hearing from you.
 
Kind regards,
Solomiia

Public
Peter Mei August 17, 2023

Hi Solomia,
The filter works when I use you sample project in our guide about using the Data Server as a DLL.
Your sample project uses custom data source but we use SQL Server as data source. Does the filter support SQL server? I also attach the pdf file which has screen shot and codes.
Thanks
Your sample project data source setting:

"Type": "custom",
    "Indexes": {
      "custom-index": null
    }
Our custom API data sources setting:
{
"Type": "database",
"DatabaseType": "mssql",
"ConnectionString": "Server=localhost;Database=CAY_WebApp_QA3_FT;Integrated Security=True;MultipleActiveResultSets=True;App=EntityFramework",
"Indexes": {
"index_personnel": {
"Query": "select * from [Person].[PersonnelReportView]",
"filters": true
}
}
}

Attachments:
filter error.pdf

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster August 21, 2023

Hello, Peter!

Thank you for the provided details.

Our team is currently working on your case. We will be back to you with the updates soon.

Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster August 21, 2023

Hello, Peter!
 
Thank you for giving us some time.
 
Our team could not reproduce the described behavior on our side.
As a next step, we kindly request your assistance with the following points:

  1. Are you sending any information to the server using customizeAPIRequest API call? If so, please provide us with more details.
  2. Could you please show us the request which returns the 400 response? You can find it in the Network tab of your browser's DevTools.

This information would help us greatly to continue the investigation.
 
Looking forward to hearing from you.
 
Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster August 29, 2023

Hello, Peter!

Hope you are doing well.

Our team is wondering if you had a chance to look through our previous response. Could you please provide us with the mentioned information so we can continue the investigation?

Looking forward to hearing from you.

Kind regards,
Solomiia

Public
Peter Mei August 30, 2023

Hi Solomia,
1. We do send information to the server using customizeAPIRequest API call. Bearer token is added for security reason
function customizeAPIRequestFunction(req) {
        req.requestHeaders = {
          "Authorization": `Bearer ${authServ.getTokenFromLocalStorage()}`,
        };
        return req;
      }
 
2. Please see attached file for 400 error detail
 

Public
Peter Mei August 30, 2023

There is another attached file for screen shot of 400 error:
"Could not create an instance of type Flexmonster.DataServer.Core.Models.Select.BaseFilter. Type is an interface or abstract class and cannot be instantiated. Path 'query.filter.value[0].field', line 1, position 113."

Attachments:
select API call.jpg

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster August 30, 2023

Hello, Peter!
 
Thank you for getting back to us.
 
As we can see from the provided information, the issue is not caused by the data sent in customizeAPIRequest. Therefore, we kindly ask for the full /select request with 400 response from the first screenshot.
Here is a brief instruction on how to save the request in a JSON file in a Chrome browser:

  1. Open the corresponding request in a Network tab
  2. Go to the Payload tab
  3. Click the view source button near the "Request Payload" label
  4. Copy the raw request in a JSON format
  5. Save it in a file and send it to us.

This information would help us greatly to proceed with the investigation.
 
Looking forward to hearing from you.
 
Kind regards,
Solomiia

Public
Peter Mei August 31, 2023

 

Hi Solomia,
I put raw json text here and in attached file
{"type":"select","index":"index_database","query":{"aggs":{"values":[]},"filter":{"type":"and","value":[{"field":{"uniqueName":"EmailAddress"},"exclude":[{"member":""}]}]},"fields":[{"uniqueName":"FirstName"},{"uniqueName":"LastName"},{"uniqueName":"EmailAddress"},{"uniqueName":"PersonnelIdentifier"},{"uniqueName":"ActualSalary"},{"uniqueName":"PersonTitleDescription"},{"uniqueName":"PersonnelTypeName"}]},"page":0}

Attachments:
RequestPayload.json

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster September 1, 2023

Hello, Peter!
 
Thank you for the provided /select request.
 
Our team has researched possible reasons for the described filtering behavior and come to the conclusion that it can be caused by serializing/deserializing JSON. 
We had a similar case in the following thread: https://www.flexmonster.com/question/implementing-the-api-controller/.
 
In our Flexmonster Data Server DLL project, we use our custom System.Text.Json.Serialization package to serialize/deserialize JSON objects. If there is another JSON serializer used in your project, we think it can be the cause of such filtering behavior.
 
Could you please check the JSON serializers used in your project and let us know if our assumptions are correct?
 
Looking forward to hearing from you.
 
Kind regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster September 21, 2023

Hello, Peter!
 
Hope you are doing well.

Just checking in to ask if you had some time to check out the provided thread. Could you please let us know if it was helpful and if the issue was caused by serializing/deserializing the JSON files?
 
If further investigation is needed, please provide us with the following details:
1. Version of Flexmosnter.
2. Version of the Data Server DLL.
3. Your implementation of the handshake, if it is present.
 
Looking forward to hearing from you.
 
Kind regards,
Solomiia

Please login or Register to Submit Answer