How to send array of object from Angular to Web API Core in HttpGet?
If you’d like to pass complex data through a HTTP Get request to your , you can try dynamically generate data and pass it through the query string, like below.
params = "";
GetData() {
// generate querystring based on PropertiesParams
this.PropertiesParams.forEach((currentValue, index) => {
this.params +=
"_Properties[" +
index +
"].Name=" +
currentValue.Name +
"&" +
"_Properties[" +
index +
"].Filter=" +
currentValue.Filter +
"&";
});
this.http
.get(this.url + "/LSetting/Getsetting?" + this.params.slice(0, -1))
.subscribe(
(response: ServiceResponse) => {
if (response.success && response.data != null) {
} else console.log(response.message);
},
(error: ServiceResponse) => {
console.log(error.message);
}
);
}
Action method
[HttpGet("Getsetting")]
public async Task<ServiceResponse> GetData([FromQuery] List<PropertiesParams> _Properties)
{
return new ServiceResponse();
}
Test Result
CLICK HERE to find out more related problems solutions.