I was able to send data through params
but when I tried to send more bigger data, it threw the error such as url characters exceeded
. So, I want to send those data to the body and get it from the C# method using [FromBody]
or without frombody. The code below is the working version using params, but I can't find the working version of using data
in the angularjs
and [FromBody]
in the method.
list of regions
[{id:1, name:"test"}]
http request
return $http.get("api/region/getlocalities", { params: { regions: sendingRegions }, paramSerializer: '$httpParamSerializerJQLike' }).then(function (x) {
return x.data;
});
method
[HttpGet]
[Route("api/region/getlocalities")]
public IEnumerable<Locality> GetLocalities([FromUri]List<Region> regions)
{
return _customZoneService.GetLocalities(regions);
}
All browsers have some limit for URL length (IE 2000 e.g.). If you need to send GET with long URL... you must switch to POST and send data in body instead.