Skip to Content
author's profile photo Former Member
Former Member

Query options $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource

Hi Experts


I run the code I paste at the end of the Discussion with no problem, but if I want to display only one result

Instead of path: "/Orders",

I want to use path: "/Orders(10251)",

This error appears

Query options $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource


If I run the call on the browser, and there is no problem.


http://services.odata.org/Northwind/Northwind.svc/Orders(10251)?$expand=Customer

Is there any work around to display only one result also using the $expand

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="X-UA-Compatible" content="IE=edge">

<meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>

<script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"

id="sap-ui-bootstrap"

data-sap-ui-libs="sap.m,sap.ui.table"

data-sap-ui-theme="sap_bluecrystal">

</script>

<!-- only load the mobile lib "sap.m" and the "sap_bluecrystal" theme -->

<script>

var url = "proxy/http/services.odata.org/Northwind/Northwind.svc/";

var oModel = new sap.ui.model.odata.ODataModel(url, true);

sap.ui.getCore().setModel(oModel);

var oTable = new sap.ui.table.Table("table", { // create Table UI

title: "Northwind - Orders",

columns : [

{label: "ID", template: "OrderID" },

{label: "Date", template: "OrderDate" },

{label: "Contact Name", template: "Customer/ContactName"}

]

});

oTable.bindRows({

path: "/Orders",

// path: "/Orders(10251)",

parameters: {

expand:"Customer"

}

}); // bind the table rows

oTable.placeAt("content"); // place Table onto UI

</script>

</head>

<body class="sapUiBody" role="application">

<div id="content"></div>

</body>

</html>

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Regards

Henry

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    Posted on Jan 13, 2015 at 07:07 AM

    Hello Henry,

    the binding path in that case must be a binding path to a list.

    You can restrict the binding by defining a filter:

    var aFilters = [];
    var oFilter = new sap.ui.model.Filter("OrderID", sap.ui.model.FilterOperator.EQ, "10251");
    aFilters.push(oFilter);
    

    The filter array (aFilter) then an be used in the binding (https://sapui5.netweaver.ondemand.com/sdk/#docs/api/symbols/sap.ui.table.Table.html#bindRows).

    Best Regards,

    Florian

    Add a comment
    10|10000 characters needed characters exceeded

    • Hello Henry,

      it depends on your requirements 😉

      In your service just the read method (GET_ENTITY) was implemented, but not the query method (GET_ENTITYSET). If you have the requirement to display all "details" in e.g. a table than you could implement the method.

      Another point to consider is if the "details" entity is maybe related to a principal entity (e.g. SalesOrderItems are related to the principle entity SalesOrder). In such a case it would make sense to restrict the access to the depending entity via an association/navigation attribute between the principal entity and the depending entity (the restriction is done in the query method for the depending entity). This would result in following assuming we have a navigation attribute ToItems for the navigation from the principal entity to the depending entry (and the restrictions in the query method):

      - .../SalesOrderItems -> not allowed

      - .../SalesOrder('1000')/ToItems -> allowed

      But as written above, it depends on your requirements.

      Best Regards,

      Florian

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.