A end point in Rest API WCF is as follows
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.WrappedRequest,
ResponseFormat = WebMessageFormat.Json, UriTemplate = "/getName")]
string getName(User user);
public string getName(User user)
{
//do what ever
}
Its json request is as follows:-
{
"user":
{
"FirstName":"nuser18",
"LastName":"nuser18" ,
......
......
......
}
}
I want to know how the User class' constructor is called when the API is hit from Postman. As I want to do some complex calculations in get set for properties based on if some properties are passed or not or if some values are sent or not or sent as null etc.
It sounds like you want to access user
before it is passed to getName
. You could do that immediately after deserialization of user
.
This could help:
MSDN - OnDeserializedAttribute Class
The MSDN link shows example where it sets the value of a member of the deserialized object, which seems similar to your described goal.