0

PFB my code:

var myApp4=angular.module("upcomingEvents",[]);
    myApp4.controller("upcomingEventsController",function($scope,$http)
    {
    $scope.today=new Date();
    $scope.today=$scope.today.toISOString();
    $http({ 
    url: _spPageContextInfo.webAbsoluteUrl + "/_api/lists/getbytitle('Calendar')/items?$filter=EventDate ge datetime'"+$scope.today+"'", 
    method: "GET", 
    headers: { "Accept": "application/json;odata=verbose" } 
    }).then(function success(data)
    {
    $scope.events=data.data.d.results;



    },
function error(data)
    {

    });
});

But am getting Failed to load resource: the server responded with a status of 400 (Bad Request) error.

Thanks in advance.

1

1 Answer 1

0

You have to encode the ISOString. The query fails since it contains the ::

"/_api/lists/getbytitle('Calendar')/items?$filter=EventDate ge datetime'2018-01-01T00:00:00'"

Encoding it you get:

"/_api/lists/getbytitle('Calendar')/items?$filter=EventDate ge datetime'2014-01-01T00%3A00%3A00%0A'"
2
  • I tred to encode it using EncodeURIComponent but still no use
    – Dheeraj
    Commented Sep 19, 2018 at 5:17
  • Do you still get BadRequest?
    – Emaborsa
    Commented Sep 19, 2018 at 7:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.