I am trying to call following function (asp.net web api core) from PostMan:
[HttpPost]
public InfluencerSearchResultWithFacets Post(string q, string group, List<string> subGroups)
{
return GetSearchResult("",null,null);
}
But I get following error: A non-empty request body is required
I have setup PostMan like this:
I also tried adding to body:
From Postman tool - right pane select GET from DropDown, then enter your Web API url like http://localhost:<portnumber>/api/supplier and click on Send button. This will make a request to Web API server and get response. You can get response in JSON, XML, HTML, Text format.
ASP.NET Core supports creating web APIs using controllers or using minimal APIs. Controllers in a web API are classes that derive from ControllerBase. This article shows how to use controllers for handling web API requests.
So you can create a model like
public class Model
{
public string q { get; set; }
public string group { get; set; }
public List<string>subGroups { get; set; }
}
and use it
[HttpPost]
public InfluencerSearchResultWithFacets Post([FromBody] Model model)
{
return GetSearchResult("",null,null);
}
This is if you fit Json format. Also you can leave some parameters in URL and other pass as a body like
[HttpPost]
public InfluencerSearchResultWithFacets Post([FromUri]string q, [FromUri]string group, [FromBody]List<string> subGroups)
{
return GetSearchResult("",null,null);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With