0

I have a GET method in my C# controller

public async Task<IHttpActionResult> GetEmailTemplate(List<string> ids)

and I'm calling it in angularJs like so:

$http({
        method: 'GET',
        url: apiUrl + 'api/jobs/composeEmail',
        data: JSON.stringify(ids) //i also tried ids (which is an array)
});

but upon hitting the api the list of ids is null... when I checked the request in the developer tools, it doesn't have the data being sent.. it's like the data config in the $http request was ignored. What am I missing?

the request is working when I try to test the api using POSTMAN by sending a Body and a sample raw data of

[
 "123213",
 "444444"
]
JC Borlagdan
  • 3,318
  • 5
  • 28
  • 51
  • 1
    [try to see here](https://stackoverflow.com/questions/13760070/angularjs-passing-data-to-http-get-request) – StepUp Oct 15 '19 at 10:21

1 Answers1

2

Only query strings can be used in GET requests.

REST API: Path vs. Request Body Parameters

$http({
    method: 'GET',
    url: apiUrl + 'api/jobs/composeEmail',
    params: {ids: ids}
});
Mert Sayın
  • 309
  • 2
  • 7