in Asp.net MVC Rest Api I Have Passed The Add Parameter but in Response It Said that the parameter is missing
There is an API That works properly in Postman But When I Execute the same API in the Asp.net MVC Project it gives me a missing parameter. Below is the Rest of the API Code.
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
string Baseurl = "End Point URL";
var client = new RestClient(Baseurl + "billpay/customer-params");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Root-id", agentid);
request.AddHeader("Authorization", "Bearer " + token + "");
request.AddHeader("clientId", clientId);
request.AddHeader("ClientSecret", ClientSecret);
request.AddHeader("distributorCode", distributorCode);
request.AddHeader("content-type", "application/json");
request.AlwaysMultipartFormData = true;
request.AddParameter("agent", agentid);
request.AddParameter("billerid", billerid);
IRestResponse responsecheck = client.Execute(request);
return responsecheck;

Vishal JoshiPosted Feb 24, 2024, 1:32 PM
Hello Ajay
Try code with JSON Serialization. You should remove the headers and instead serialize the parameters into JSON format and add them to the request body.
Thanks
Ajay KumarPosted Feb 25, 2024, 5:41 AM
Thanks Buddy , Now The Problem Solved