Requirement: To send data to an endpoint using a post of data, include the startdate and endate in the querystring of the url. Here's an example:
The data payload should only contain the locationIDs and Criteria as shown below.
The Resource Definition
I attempted to move the startDate and endate out of the query object as well.
ByLocationResource: $resource(
ByLocationEndpoint,
null,
{
query: {
startDate: '@startDate',
endDate: '@endDate',
locationIds: ['@locationIds'],
Criteria: '@Criteria',
method: 'POST'
}
}
),
The EndPoint Definition
var ByLocationEndpoint = https:/servername/byLocation/?startDate=:startDate&endDate=:endDate');
How can I consolidate the querystring in the URL endpoint with the post data?
The Service:
function ByLocation(startDate, endDate, Criteria, locationIds) {
_ByLocationResource.query(
{
startDate:startDate,
endDate:endDate,
locationIds: [locationIds],
Criteria: Criteria
});
}
I experimented with this variation:
function ByLocation(startDate, endDate, Criteria, locationIds) {
_ByLocationResource(startDate,EndDate).query(
{
locationIds: [locationIds],
Criteria: Criteria
});
}
Do I have to resort to using $http instead of an endpoint and resource?
The browser shows a 400 bad request that looks like this:
Request URL:
Evidently, the startDate and endDate parameters are not being populated.