I'm trying to make a call to an MVC Web API using angular 2. The endpoint I have looks like this:
[HttpDelete]
[Route("DeleteMe")]
public ActionResult DeleteItems([FromQuery] string objectId, [FromBody] int[] toDelete) {
//logic
}
And I can test this using postman, where I set a body using the content type 'application/json', and enter the following data.
[1,2,3]
This works just fine. However I cannot recreate this call with angular 2. I am using HttpClient to make my calls, and have code similar looking to this:
public callDeleteItems(objId: number, toDelete: number[]) {
var serviceEndpoint = "endpoint here?objectId=" + objId;
const params = new HttpParams().set("toDelete", JSON.stringify(toDelete));
this.http.request('delete', serviceEndpoint, {
params: params
}).subscribe();
}