简体   繁体   中英

How to Pass List<int> parameter to SOAP UI on a Web Api C#

I have a WebApi with something like this

public HttpResponseMessage Get(List<int> Ids)
{
    //do some stuff with the List
}

I don't know if I have to do it POST because of that list or if I can use Get and recieve a list of int, I'm using SOAP UI here is a SS.

SOAP UI屏幕截图

As far as the code is concerned, you should consider the following...

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
}

Also have a look at how parameter binding works in Web Api.

https://www.asp.net/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM