I have the following:
[HttpDelete]
public HttpResponseMessage DeleteFolder(int[] ids)
{
and I'm trying to use this:
DELETE http://localhost:24144/api/folder/1483;
DELETE http://localhost:24144/api/folder/[1483]
but these are coming up as null within the delete method - how do I send the data without putting it in the body (since this is a DELETE request)?
My routing has this:
routes.MapHttpRoute(
name: "Folder",
routeTemplate: "api/folder/{id}",
defaults: new { controller = "Folder", id = RouteParameter.Optional }
);
Arrays can be passed as arguments to method parameters. Because arrays are reference types, the method can change the value of the elements.
Step1: Create a Blank Solution called WebAPI-Multiple-Objects as shown below. Add a new class library project (Model) into it and create two classes named Product, Supplier. Now, on the API controller side, you will get your complex types as shown below.
Passing Data in your API Calls REST API endpoints can pass data within their requests through 4 types of parameters: Header, Path, Query String, or in the Request Body.
Nevermind, I found this:
http://blog.codelab.co.nz/2012/10/16/passing-arrays-into-asp-net-web-api-as-parameters/
Couldn't find an answer on SO though so I'll leave it here.
Exerpt from the above linked page:
[HttpGet()]
public HttpResponseMessage FindByMembers([FromUri]Int32[] ids = null)
{
//Do stuff
return Request.CreateResponseMessage(HttpStatusCode.OK);
}
The Url will be http://mywebsite/api/mycontroller/findbymembers/?ids=1&ids=2&ids=3.
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