This is a migrated thread and some comments may be shown as answers.

ODATA - Error: Query options $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource.

1 Answer 1148 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 29 Oct 2013, 02:06 AM
I am using WCF Data Service 5.6 to return JSON data:

DATA SERVICE CLASS
public static void InitializeService( DataServiceConfiguration config )
{
    config.SetEntitySetAccessRule( "*", EntitySetRights.AllRead );
    config.SetServiceOperationAccessRule( "*", ServiceOperationRights.All );
    config.DataServiceBehavior.MaxProtocolVersion= DataServiceProtocolVersion.V2;
}
[WebGet]
     public IQueryable<Tournament_Players_Result> Tournament_Players( int tournamentID )
     {
            return this.CurrentDataSource.Tournament_Players( tournamentID ).AsQueryable();
      }

Binding the data to a kendoGrid:

SCRIPT
var playersDataSource = new kendo.data.DataSource({
        type: "odata",
        transport: {
               read: {
                      url: http://localhost:41698/Tournament.svc/Tournament_Players?tournamentID=1,
                      dataType: "json"
                }
         }
});

$(document).ready(function () {
       $("#playersGrid").kendoGrid({
                dataSource: playersDataSource,
         });
});

Getting an error message:
ERROR
{"error":{"code":"","message":{"lang":"en-US","value":"Query options $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource."}}}

Without the type="odata" in DataSource the service returns:
{"d":[{"__metadata":{"type":"TournamentModel.Tournament_Players_Result"},"PlayerID":1,"FirstName":"Tiger","LastName":"Woods","Handicap":null,"StartTime":"\/Date(1365674400000)\/","StartHole":"Mako #1"},{"__metadata":{"type":"TournamentModel.Tournament_Players_Result"},"PlayerID":2,"FirstName":"Adam","LastName":"Scott","Handicap":null,"StartTime":"\/Date(1365674400000)\/","StartHole":"Mako #1"},{"__metadata":{"type":"TournamentModel.Tournament_Players_Result"},"PlayerID":3,"FirstName":"Phil","LastName":"Mickelson","Handicap":null,"StartTime":"\/Date(1365675300000)\/","StartHole":"Mako #1"},{"__metadata":{"type":"TournamentModel.Tournament_Players_Result"},"PlayerID":4,"FirstName":"Henrik","LastName":"Stenson","Handicap":null,"StartTime":"\/Date(1365675300000)\/","StartHole":"Mako #1"},{"__metadata":{"type":"TournamentModel.Tournament_Players_Result"},"PlayerID":5,"FirstName":"Justin","LastName":"Rose","Handicap":null,"StartTime":"\/Date(1365676200000)\/","StartHole":"Hammerhead #1"},{"__metadata":{"type":"TournamentModel.Tournament_Players_Result"},"PlayerID":6,"FirstName":"Rory","LastName":"McIlroy","Handicap":null,"StartTime":"\/Date(1365676200000)\/","StartHole":"Hammerhead #1"}]}

Any help would be welcomed!

Thanks,

Greg.

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 30 Oct 2013, 12:33 PM
Hello Greg,

It looks like using the AsQueryable() extensions method is not enough to consider the collection that you return as queryable.

Here is similar questions on SO:

http://stackoverflow.com/questions/8422402/cant-call-expand-on-service-operation-result

http://stackoverflow.com/questions/8792977/query-options-cannot-be-applied-to-the-requested-resource


Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Greg
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or