Good day, I am sending a post request to Localhost for an API end point using Postman but facing an issue. Postman Body Relevant C# method is as below:
public IActionResult SavePaymentPlan(string obj)
{
DebtPaymentInfo info = JsonConvert.DeserializeObject<DebtPaymentInfo>(obj);
IActionResult response = Unauthorized();
}
I know in Postman is requiring obj of above method. How to mention this in Postman body?
I have tried to mention obj in different ways but nothing worked.
There is a mismatching of the data you pass (JSON) and what server is expected (string). Few improvements:
Use JsonObject
OR custom dto instead of a string.
[HttpPost("SavePaymentPlan")]
public IActionResult SavePaymentPlan([FromBody] JsonObject obj)
{
return Ok(obj);
}
And then pass a JSON data from Postman.
If you want to pass it as a string, then convert JSON object to a string and then send it.
"{\"isPaymentPlanAvailable\":false}"