Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

Issue with the get Fields API and the types for each field

Michael Kumm asked on March 10, 2021

I tested FlexMonster out with the Data Server which you run via the executable and connected to MSSQL database. Everything worked fine here.
I then tried to implement the data service in our .NET API after some struggles (We use Azure Functions HTTP Trigger), I managed to get things to run and the reports on the front end talking to the API in our Azure Functions.
I did however run into a strange problem, I now notice that when adding any measure now, it only gives me the option of count and distinct count. The values I am using are numbers. I did notice something in the /fields API call. When I point my reports to the Flex Monster executable, I notice it returns “uniqueName” and “type” but the value for “type” is either “number”, “string” or “date”.
When I point this to the .NET implementation, I notice this returns 1, 2, 3 for the field type. So I am almost certain its then applying the aggregation {any} to my data. 
I have made sure I am on the latest version in .NET i.e. 2.8.28 and have the same version in our Angular project. I did dig into the models of the NuGet package “FlexMonster.DataService.Core” and I see the types in the Fields model are Enums. Is there any property I need to set on the front end or report configuration to change the way it handles these fields?
Kind Regards

6 answers

Milena Pechura Milena Pechura Flexmonster March 11, 2021

Hello, Michael!
Thank you for the detailed explanation of the issue and for providing the screenshots.
Our team has investigated your question and came up with the idea of why the types in the /fields response have numeric values. We assume that this behavior is related to the JSON library used in the project.
Therefore, could you please let us know whether you use any third-party library for converting responses to JSON (e.g. Newtonsoft)? If so, please inform us which one. This info will greatly help us to find the solution for your case.
Looking forward to hearing from you.
Best regards,

Michael Kumm March 11, 2021

Hi Milena,
Thanks for your response.
We not using any specific library to convert the object back to JSON, I am just passing the object back via OkObjectResult as you will see in my one screenshot. (I did try some other options to convert to JSON but made no difference, still see the 1, 2, 3.
I have also attached a screenshot of the debugger with the response as it looks after doing the GetFields call. I have then drilled into the FlexMonster Library to show why it seems to me that its passing 1, 2, 3 as that’s the value in the Enum.
Hopefully, the screenshots will help. Once again to confirm, I am using FlexMonster.DataService.Core (2.8.28).
Kind Regards

Milena Pechura Milena Pechura Flexmonster March 12, 2021

Hello, Michael,
Thank you for providing further information about the case.
We would like to suggest several solutions to try:

  1. If your application is based on ASP.NET and you have a Startup class or something similar, you can specify a JSON converter like this:
    services.AddControllers().AddJsonOptions(options =>
    options.JsonSerializerOptions.IgnoreNullValues = true; // not neccessary, but recommended line
    options.JsonSerializerOptions.Converters.Add(new Flexmonster.DataServer.Core.JsonConverters.ColumnTypeJsonConverter());
  2. Or change the response to this:
    var serializerSettings = new System.Text.Json.JsonSerializerOptions();
    serializerSettings.Converters.Add(new Flexmonster.DataServer.Core.JsonConverters.ColumnTypeJsonConverter());
    return new JsonResult(response, serializerSettings);

Please kindly note that our dev team does not have much experience with Azure Functions, so the code above is just an example that could possibly help. You are welcome to customize it to your needs.
In case our suggestions do not work for you, please notify us, and we will do some modifications to Flexmonster Data Server to resolve your issue.
Looking forward to hearing your feedback.
Best regards,

Milena Pechura Milena Pechura Flexmonster March 18, 2021

Hi, Michael,
We were wondering whether our suggestions helped.
Please let us know if everything works fine now or if further assistance is needed.
Waiting for your reply.
Kind regards,

Michael Kumm March 19, 2021

Hi Milena,
Apologies for the delay. 
I did manage to try your suggestions and it is now returning the types of the field as strings and not integers, so the suggestions you provided did work 😀
Thanks again for all the help.
Kind Regards

Milena Pechura Milena Pechura Flexmonster March 19, 2021

Hello, Michael,
Thank you for sharing the feedback!
We are happy to know that the issue is resolved.
Do not hesitate to contact us if any further questions arise.
Best regards,

Please login or Register to Submit Answer