Santhosh S

Santhosh S

  • 1.7k
  • 33
  • 616

How to handle datatype missmatch values in .net core api?

May 10 2023 8:04 PM

Hello,

How to handle datatype missmatch values in .net core api request object.

Examble :

Have a api request object like below

Class math{

public int number1 {get; set;}

public int number2 {get; set;}

public bool isActive {get; set;}

}

 

From the request (postman or any other client)

calling the api with below set of request

{

number1 : 20,

number2 : 10,

isActive : "True"

}

 

The above sample isActive is bool type, but from the request client its like String

Getting the below exception :

The JSON value could not be converted to System.Nullable`1[System.Boolean]'

Thanks in Advance.


Answers (1)