I'm struggling to figure out the proper way to send an array of objects to my API using AngularJS.
FrontEnd Code:
function fetchPrices(articles) {
return $http.get('http://someurl/api/prices/getprices', { params: { articles: articles } }).then(function (res) {
// perform actions on prices
}, function (err) {
// handle errors
});
}
The structure of Articles is as follows:
var oneArticle = {
code: 'someCode',
quantity: 1,
stockUnit: 'piece'
}
API code:
[VersionedRoute("getprices")]
[HttpGet]
public IHttpActionResult RetrievePrices([FromUri]List<Article> articles) {
// process input data
}
Article class details:
public class Article {
public string Code {get;set;}
public int Quantity {get;set;}
public string StockUnit {get;set;}
}
Some inquiries:
1) Why does my API not receive any data? The "Articles" object always remains null.
2) Is this the correct methodology to follow?
Thank you
EDIT 1: After utilizing a post option, I am receiving the displayed data in my request. However, I am unsure about how to manage it within the API.