I'am trying to get calendar items and filtering by EventDate and EndDate fields using rest api. DateTime field filtering works fine on other lists but I can not filter calendar items by EventDate and EndDate. Exact same issue with this.
At powershell I'm getting this error when I try to filter by EventDate field
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
Is there anybody know how to solve this without using ListData.svc?
This works great
$restUrl="http://www.myspportal.com/sites/Dev/_api/web/lists/getbytitle('RestTestCalendar')/items?`$select=*&`$filter=Title eq 'test'"
$response=Invoke-RestMethod -Uri $restUrl -Method Get -UseDefaultCredentials -Headers @{ "Accept" = "application/json;odata=verbose" }
$response=$response -creplace '"ID":','"ListItemID":'
$items = $response| ConvertFrom-Json
foreach($item in $items.d.results)
{
write-host "Title `t-->" $item.Title
}
but this is not working
$restUrl="http://www.myspportal.com/sites/Dev/_api/web/lists/getbytitle('RestTestCalendar')/items?`$select=*&`$filter=Title eq 'test' or EventDate eq datetime'2018-05-09T09:00:00Z'"
$response=Invoke-RestMethod -Uri $restUrl -Method Get -UseDefaultCredentials -Headers @{ "Accept" = "application/json;odata=verbose" }
$response=$response -creplace '"ID":','"ListItemID":'
$items = $response| ConvertFrom-Json
foreach($item in $items.d.results)
{
write-host "Title `t-->" $item.Title
}
Getting this error
Also logs say this
The field 'EventDate' of type 'DateTime' cannot be used in the query filter expression
$select=*&
$filter=Title eq 'test' or EventDate eq datetime'[uri]::EscapeDataString(2018-05-09T09:00:00Z)'"