REST API SharePoint Online - URL client.svc stopped working

Hi there

I have a code that pulls data from a list on SharePoint Online site.

The URL was set to /_vti_bin/client.svc/web/Lists.getByTitle('ListName') and this worked and picked up all the values. Until last week when it stopped picking up any further entries made to the list.

I changed the URL on the AJAX code to /_vti_bin/ListData.svc/ListName and this fixed the problem and it started picking up all the list entries.

$.ajax({
	       //url: "https://SPSITE/_vti_bin/client.svc/web/Lists/getByTitle('ListName')/items?$filter=(Site eq '"+site+"')&$orderby=Date asc",
	        url: "https://SPSITE/_vti_bin/ListData.svc/ListName()?$orderby=Date asc&$filter=(Site eq '"+site+"')",
	        method: "GET",
	        headers: { "Accept": "application/json; odata=verbose" },
	       	success: function (data) {
		    $.each(data.d.results, function (index,value){
                    })
		},
		error: function (data) {
		            //failure(data);
		}
	})

From my research I understand that the ListData.svc is the older one that was for SP 2010 and Client.svc is the newer one for SP 2013.

The change of URL caused all values from a particular currency column to return as undefined. When I change the URL back, the value is returned successfully.

Has anyone else had the same problem? Any ideas on how I could fix it?


  • Edited by teaa 16 hours 13 minutes ago missed closing bracket
September 14th, 2015 6:40am

Hi,

Please use "/_api/" instead of the "/_vti_bin/client.svc/" in SharePoint 2013. The following code for your reference:

<script src="http://code.jquery.com/jquery-1.11.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
    
        var listName="Custom List Name";
        var site="Site Name";
		
        var requestUri = _spPageContextInfo.webAbsoluteUrl +
                      "/_api/Web/Lists/getByTitle('"+listName+"')/items?$filter=Site eq '"+site+"'&$orderby=Date asc";

        //execute AJAX request
        $.ajax({
            url: requestUri,
            type: "GET",
            headers: { "ACCEPT": "application/json;odata=verbose" },
            success: function (data) {
                if(data.d.results.length>0){
                	alert("data");
                }else{
                	alert("no data");
                }
            },
            error: function () {
                //alert("Failed to get details");                
            }
        });
    });
</script>

More information:

http://www.plusconsulting.com/blog/2013/05/crud-on-list-items-using-rest-services-jquery/

Best Regards,

Dennis

Free Windows Admin Tool Kit Click here and download it now
September 15th, 2015 3:02am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics