如何在 Web Api C# 上将列表<int> 参数传递给 SOAP UI
How to Pass List<int> parameter to SOAP UI on a Web Api C#
我有一个类似这样的 WebApi
public HttpResponseMessage Get(List<int> Ids)
{
//do some stuff with the List
}
我不知道我是否必须这样做 POST 因为那个列表,或者我是否可以使用 Get 并接收一个 int 列表,我正在使用 SOAP UI 这里是SS.
就代码而言,您应该考虑以下...
FromUri:
[HttpGet]
public HttpResponseMessage GetListFromUri([FromUri] List<int> ids)
{
//do some stuff with the List
}
FromBody:
[HttpPost]
public HttpResponseMessage GetListFromBody([FromBody] List<int> ids)
{
//do some stuff with the List
}
另请查看参数绑定在 Web 中的工作原理 Api。
https://www.asp.net/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api
我有一个类似这样的 WebApi
public HttpResponseMessage Get(List<int> Ids)
{
//do some stuff with the List
}
我不知道我是否必须这样做 POST 因为那个列表,或者我是否可以使用 Get 并接收一个 int 列表,我正在使用 SOAP UI 这里是SS.
就代码而言,您应该考虑以下...
FromUri:
[HttpGet]
public HttpResponseMessage GetListFromUri([FromUri] List<int> ids)
{
//do some stuff with the List
}
FromBody:
[HttpPost]
public HttpResponseMessage GetListFromBody([FromBody] List<int> ids)
{
//do some stuff with the List
}
另请查看参数绑定在 Web 中的工作原理 Api。
https://www.asp.net/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api