The API (written in C#, ASP.NET Core) receive 3 fields: title, content and an array of categories (integers):
[HttpGet]
[AllowAnonymous]
public IActionResult CreatePublication(string title, string content, IEnumerable<int> categoryIds)
{
return Ok();
}
The problem is the API always receive zero elements in the categoryIds array.
The client in Angular4:
let ccategoryIds = new Array<number>()
ccategoryIds.push(2)
ccategoryIds.push(5)
ccategoryIds.push(7)
let requestOptions = {
params: new HttpParams()
.set('title', 'The title')
.append('content', 'The content')
.append('categoryIds', ccategoryIds.toString()),
withCredentials: true
}
this.http
.get('http://localhost:53203/api/publications/createPublication', requestOptions)
.subscribe(data => {
},
(err: HttpErrorResponse) => {
alert('Error')
})
Update
If I use JSON.stringify(ccategoryIds) instead of ccategoryIds.toString(), I receive zero elements in the API too.


