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

Query options are not allowed

7 Answers 174 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Michal Revivo
Top achievements
Rank 1
Michal Revivo asked on 29 Dec 2011, 09:21 AM
Hi
I successfully created a dataService with EF4 and OData enable
my uri is http://myserver/sa2.Web/sa2-Web-DomainService1.svc/OData/UserSet
And i successfully see the data using the OdataExplorer
http://www.odata.org/developers/odata-sdk

But when I try to retrieve the data to kendoGrid i obtain an error

<script type="text/javascript">
                $(document).ready(function () {
                    $("#grid").kendoGrid({
                        dataSource: {
                            type: "odata",
                            transport: {
                                read: "http://myserver/sa2.Web/sa2-Web-DomainService1.svc/OData/UserSet"
                            }
                        },
                        columns: ["Id", "name"]
                    });
                });
            </script>

The table name is User with 2 columns Id and name

Could you help ?????
Thanks
Fred

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code/>
<message xml:lang="en-US">Query options are not allowed.</message>
</error>

7 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 29 Dec 2011, 10:09 AM
Hi,

We are not sure what is causing this problem. However the service should return results when the URL is requested by pasting it in the browser address bar. Probably this is caused by some OData configuration issue. 

All the best,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michal Revivo
Top achievements
Rank 1
answered on 29 Dec 2011, 12:51 PM
Hi
i obtain also this error
any idea what to do ?
XMLHttpRequest cannot load http://myserver/sa2.Web/sa2-Web-DomainService1.svc/OData/UserSet. Origin http://localhost:49424 is not allowed by Access-Control-Allow-Origin.

in the browser
http://myserver/sa2.Web/sa2-Web-DomainService1.svc/OData/UserSet
returns

<?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
<feed xml:base="http://myserver/sa2.Web/Services/sa2-Web-DomainService1.svc/OData/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <title type="text">UserSet</title>
  <id>http://myserver/sa2.Web/Services/sa2-Web-DomainService1.svc/OData/UserSet</id>
  <updated>2011-12-29T11:48:10Z</updated>
  <link rel="self" title="UserSet" href="UserSet" />
  <entry>
    <id>http://myserver/sa2.Web/Services/sa2-Web-DomainService1.svc/OData/UserSet(1)</id>
    <title type="text"></title>
    <updated>2011-12-29T11:48:10Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="User" href="UserSet(1)" />
    <category term="sa2.Web.User" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Id m:type="Edm.Int32">1</d:Id>
        <d:name>fred</d:name>
      </m:properties>
    </content>
  </entry>
  <entry>
    <id>http://myserver/sa2.Web/Services/sa2-Web-DomainService1.svc/OData/UserSet(2)</id>
    <title type="text"></title>
    <updated>2011-12-29T11:48:10Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="User" href="UserSet(2)" />
    <category term="sa2.Web.User" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Id m:type="Edm.Int32">2</d:Id>
        <d:name>toto</d:name>
      </m:properties>
    </content>
  </entry>
</feed>

0
Atanas Korchev
Telerik team
answered on 29 Dec 2011, 01:02 PM
Hi,

 When do you receive this error? Such an error will occur if you are trying to request the service using $.ajax because cross domain ajax requests are not allowed by the browsers. However if you are using an odata DataSource this problem should not be present.

Something strange is going on. Could you paste the declaration of your OData service? 

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michal Revivo
Top achievements
Rank 1
answered on 29 Dec 2011, 04:29 PM

Hi

<

 

add name="OData" type="System.ServiceModel.DomainServices.Hosting.ODataEndpointFactory, system.ServiceModel.DomainServices.Hosting.OData, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

 

"NetworkError: 401 Unauthorized - http://fhayounw7/sa2.Web/sa2-Web-DomainService1.svc/OData/UserSet"

I obtain now this error
could you help ?
Thanks
Fred
0
Atanas Korchev
Telerik team
answered on 29 Dec 2011, 04:35 PM
Hello,

We are not sure what may cause this error as it seems to be generated server side. Most probably this is not related to Kendo but is caused by some configuration setting.

  I suggest you try looking for a solution online. For example searching for "NetworkError: 401 OData" returns a few results which may be helpful.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Michal Revivo
Top achievements
Rank 1
answered on 01 Jan 2012, 07:47 AM

Hi
I successfully implement an ajax application using json.
i try now to use gridKendo, but the grid is emply

my script is as following
<script type="text/javascript">
                $(document).ready(function () {
                    $("#grid").kendoGrid({
                        dataSource: {
                            url: "data.json",
                            type: "json",
                            transport: {
                                read: "http://localhost:53814/sa3-Web-DomainService1.svc/JSON/GetUsers"
                            }
                        },
                        columns: ["Id", "name"]
                    });
                });
            </script>
   
What is missing, since I obtain any error in firebug
GET http://localhost:53814/sa3-Web-DomainService1.svc/JSON/GetUsers
200 OK
GetUsersResult
Object { TotalCount=2, RootResults=[2]}
TotalCount
2
RootResults
[Object { Id=1, name="fred"}, Object { Id=2, name="toto"}]
0
Object { Id=1, name="fred"}
1
Object { Id=2, name="toto"}

{"GetUsersResult":{"TotalCount":2,"RootResults":[{"Id":1,"name":"fred"},{"Id":2,"name":"toto"}]}}

0
Atanas Korchev
Telerik team
answered on 02 Jan 2012, 09:51 AM
Hi,

 Could you please specify how the result JSON looks like? Is it like this:

{"GetUsersResult":{"TotalCount":2,"RootResults":[{"Id":1,"name":"fred"},{"Id":2,"name":"toto"}]}}


If yes then you need to configure your DataSource to read the data from "GetUsersResult.RootResults":

dataSource: {
     schema: {
         data: "GetUsersResult.RootResults"
     }
,

     transport: {

            read: "http://localhost:53814/sa3-Web-DomainService1.svc/JSON/GetUsers"

     }
}

Regards,
Atanas Korchev
the Telerik team
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
Michal Revivo
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Michal Revivo
Top achievements
Rank 1
Share this question
or