I'm using this npm package : o.js to manipulate oData service
I'm trying to fetch an entity, but I want to add a filter : get only where the LastChangeDateTime is greater than the past five minutes
what I am doing wrong?
The query :
static async fetchRecentProjectTasks(odataHandler) {
var pastFiveMinutes = moment().subtract(5, 'minutes').format();
return await odataHandler.get('ProjectTaskCollection').query({
$filter: `LastChangeDateTime ge datetime'${pastFiveMinutes}'`,
$top: parseInt(20000),
$select: "ObjectID,LastChangeDateTime",
$orderby: "ObjectID",
$format: 'json'
});
}
This is the output of the request :
Error :
{"error":{"code":"","message":{"lang":"en","value":"Invalid parametertype used at function 'ge'"}}}
I've solved it by trying a different approach of string concatenation, and I've used the
datetimeoffset
while formatting the date totoISOString()
I don't understand what was wrong in the first query but whatever, as long as it works