I know there are tons of answers for this topic, but couldn't find the solution to my issue.
I have an ASP.NET MVC Web API that looks like this:
[HttpGet]
public IList<Country> GetCountryList(List<long> idList)
And I've tried calling it like this:
$.ajax({
dataType: "json",
data: JSON.stringify({idList: listOfIds}),
type: "GET",
url: "api/v1/util/CountryList",
success: function (result) {
alert(result);
}
});
The URL then looks like this:
https://localhost/supertext/api/v1/util/CountryList?{%22idList%22:[46,14,62,83,120]}
Alternative:
$.ajax({
dataType: "json",
data: {
idList: JSON.stringify(listOfIds),
}
type: "GET",
url: "api/v1/util/CountryList",
success: function (result) {
alert(result);
}
});
URL:
https://localhost/supertext/api/v1/util/CountryList?idList=%5B46%2C14%2C62%2C83%2C120%5D
Both methods don't work.
Do I really have to send and receive it as a string or use POST?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…