Reputation: 2136
I have a service in which I would like to be able to send an array of Ids with a single http.delete. So far I have the following:
`
removeLeaguePictures(leaguePics: LeaguePicture[]) {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json"
}),
body: {
idss: JSON.stringify(leaguePics.map(lp => lp.id))
}
};
return combineLatest([
this.leaguePictures$,
this.http.delete<boolean>(this.galleryUrl, options)
]).pipe(...)
`
this however does not seem to be sending the list or I just do not know how to retrieve it on the back end Asp.Net core endpoint
In my backend server I have the following action :
`
[HttpDelete]
public async Task<ActionResult<bool>> Delete([FromBody] long[] ids)
{...}
`
But I cannot get the ids array to be populated. Any ideas what I am doing wrong?
Upvotes: 0
Views: 820
Reputation: 4794
Try it a little bit different:
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json"
}),
body: JSON.stringify(leaguePics.map(lp => lp.id))
}
Upvotes: 1