mercredi 11 mars 2015

SharePoint 2010 Rest API filter statement not working



I am trying to filter a rest query but can't seem to get it to work.


During my testing, the following statement works (no filter, a alternate way to get the item I wanted):



// sort the list desc and grab the top item
var url = "../_vti_bin/http://ift.tt/1AfsN2f desc&$top=1&$expand=RiskHealth,ScopeHealth,ScheduleHealth,CostHealth,ProjectStage";


This one, with a filter, doesn't work:



// grab an item by the report ID
var url = "../_vti_bin/http://ift.tt/1BoBhZJ'1'&$expand=RiskHealth,ScopeHealth,ScheduleHealth,CostHealth,ProjectStage";


I tried these too:



var url = "../_vti_bin/http://ift.tt/1AfsN2h eq '1'&$expand=RiskHealth,ScopeHealth,ScheduleHealth,CostHealth,ProjectStage";
var url = "../_vti_bin/http://ift.tt/1BoBhZL(ReportId eq '1')&$expand=RiskHealth,ScopeHealth,ScheduleHealth,CostHealth,ProjectStage";


When I use the filtered version I get the following results:



$.getJSON(url, function (data) {
alert(data); // returns [object Object]
alert(data.d); // returns [object Object]
alert(data.d[0]); // returns undefined
alert(data.d.results); // returns undefined
alert(JSONdata.stringify(data.d)); // alert doesn't fire
alert(JSONdata.stringify(data)); // alert doesn't fire
});


Any help is appreciated


Edit: I did test all three in the browser address bar and they all work








0 commentaires:

Enregistrer un commentaire