I'm trying to create a custom JSON Response message on C# Web API. Right now Web Api only returns the parameter inserted by the user on Web API. I want the Web API to returning the response code and respond message along with the parameter. I'm trying to create a JSON object with returning data and response message inside like this
JObject _jo = new JObject
{
{ "Data", value },
{ "Response Code:", Constant.RESP_SUCCESS },
{ "Respnse Message", " Success"}
};
but there is an exception is thrown
CS1503 Argument 2: cannot convert from 'His_sso_final.Services.TacVerify_Model' to 'Newtonsoft.Json.Linq.JToken'
And this is the actual response I get using the method HttpResponseMessage verifyAccessToken
Actual Response
[
{
"customer_id": "LCE500008_2021 "
}
]
Expected Response
{
"customer _id": "LCE202101245002",
"response": {
"code": 00,
"response_message": "Success"
}
}
Method to call Web Api
public HttpResponseMessage verifyAccessToken(TacVerify_Model value)
{
try
{
TacVerify_Model _return = value;
SSOService objCrd = new SSOService();
List<TacVerify_Model> modelCust = objCrd.DoTacVerify(value);
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, modelCust);
return response;
}
catch (Exception ex)
{
throw ex;
}
}