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

invalid label "d" : {

10 Answers 208 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 11 Dec 2011, 04:21 AM
I'm trying to bind the KendoDS to a simple oData method

[WebInvoke(Method = "GET")]
        [WebGet]
        public string HelloGET() {
            return "Hi THere from GET";
        }

var helloDS = new kendo.data.DataSource({
        transport: {
            read: {
                // the remote service URL
                type: "GET",
                url: oDataBasePath + "/USDA.svc/HelloGET?$format=json",
                dataType: "jsonp",
                contentType: "application/json; charset=utf-8",
            }
        },
        change: function () {
            alert("Change");
        },
        error: function(){
            alert("error");
        }
    });
 
    helloDS.fetch();

So I see the GET works, I get my JSON back
{
"d" : {
"Hello": "Hi THere"
}
}

But Firebug throws the error:
invalid label

This is the callback from Firebug
http://odata.gourmetsleuth.com/USDA.svc/HelloGET?$format=json&callback=jQuery17106241045930093632_1323571371269&_=1323573597895

So I'm getting my callback method

What am I doing wrong here?  Shouldn't the odata method be returning that callback ID in the result?

10 Answers, 1 is accepted

Sort by
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 11 Dec 2011, 05:31 AM
If I change it to this:

type: "odata",
transport: {
            read: oDataBasePath + "/USDA.svc/HelloGET"
        },

Then it formats the url as
http://odata.gourmetsleuth.com/USDA.svc/HelloGET?$format=json&$inlinecount=allpages&$callback=callback

However...that throws an error
callback({
"error": {
"code": "", "message": {
"lang": "en-US", "value": "Query options $expand, $filter, $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource."
}
}
})

...so I assume it needs to just be JSONP?
0
Accepted
Rosen
Telerik team
answered on 13 Dec 2011, 11:33 AM
Hi Steve,

As you may know the remote transport of our DataSource is using jQuery ajax behind the scene. Thus calling odata service will require some additional settings:


However, note that dataSource expects an array to which to be bound, thus the service method you are using will not work as it is returning a string, which I suspect is the cause for the server error when default odata binding is used.

Greetings,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
jeff moeller
Top achievements
Rank 1
answered on 06 Jan 2012, 06:32 PM
I'm also having a similar issue:

I originally got this:
  "Query options $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource."

But after adding the jsonp specific code from above I get:
  "The query parameter '$format' begins with a system-reserved '$' character but is not recognized"

[JSONPSupportBehavior]
  public class MarketTopologyService : DataService<USOPEntities>
  {
      public static void InitializeService(DataServiceConfiguration config)
      {
          config.SetEntitySetAccessRule("TblZZZZ_Hierarchy", EntitySetRights.AllRead);           
          config.SetServiceOperationAccessRule("GetRegions", ServiceOperationRights.All);           
          config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
      }
 
      [WebGet]
      public IQueryable<GetRegions_Result> GetRegions()
      {
          return CurrentDataSource.GetRegions().AsQueryable<GetRegions_Result>();
      }
  }

$("#lstRegion").kendoDropDownList({
       index: 0,
       dataTextField: "Region_Name",
       dataValueField: "Region_Name",
       filter: "contains",
       dataSource: {
           type: "odata",
           severFiltering: true,
           serverPaging: true,
           pageSize: 20,
           transport: {
               read: {
                   url: "http://localhost/HtmlZZZZ/ZZZZZ/ZZZZZService.svc/GetRegions?$format=json&$callback=callback",
                   dataType: 'jsonp',
                   cache: true,
                   jsonp: false,
                   jsonpCallback: 'callback'
               }
           }
       }
   });

Jeff Moeller - AT&T
0
Rosen
Telerik team
answered on 09 Jan 2012, 10:47 AM
Hi jeff,

As the dataSource will set the $format not $callback internally, you should not append them to the URL manually. Therefore, please remove it from the URL and see if there is a change in the observed behavior.

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
jeff moeller
Top achievements
Rank 1
answered on 09 Jan 2012, 04:14 PM
I tried both of these:



and still got:

"Query options $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource."
0
Rosen
Telerik team
answered on 10 Jan 2012, 08:32 AM
Hello Jeff,

Could you please provide a small sample which demonstrates the issue you are facing?

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Courouble Damien
Top achievements
Rank 1
answered on 17 May 2012, 11:56 AM
Any updates on that issue ? 

Thanks
0
Mentor Graphics
Top achievements
Rank 1
answered on 27 May 2012, 07:55 PM

Hello - i have similar issue:
I want to bind a pie chart to a json (aspx based) datasource.
here is the client side code i implemented:

var sharableDataSource = new kendo.data.DataSource({
            transport:
            {
                read: {
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "HttpHandler.aspx/Top5Defects",
                    dataType: "json"
                }
            },
            error: function (e) {
                alert(e);
            }
        });

function createChart() {
            $("#chart").kendoChart({
                theme: $(document).data("kendoSkin") || "default",
                title: {
                    text: "Top 5 Defects"
                },
                legend: {
                    position: "bottom"
                },
                seriesDefaults: {
                    labels: {
                        visible: true,
                        format: "{0}"
                    }
                },
                 tooltip: {
                            visible: true,
                            format: "{0}%"
                        },
                dataSource: sharableDataSource,
                series: [{
                    type: "pie",
                    field: "DefectCount" ,
                    categoryField: "Defect"                  
                }]
            });        
        }

        $(document).ready(function () {
            setTimeout(function () {
                createChart();              
            }, 400);
        });

Here is what returned from my aspx web method (aspx encapsulates json data in the d property):
{"d":[{"Defect":"65-Missing solder -  printer\\sten","DefectCount":"3983"},
        {"Defect":"16-Pin in air / Tombston","DefectCount":"1871"},
        {"Defect":"41-Shift component","DefectCount":"1598"},
        {"Defect":"9-NFF-no failure found","DefectCount":"1489"},
        {"Defect":"82-Missing solder","DefectCount":"1462"}]}

For some reason, the Pie chart is not being displayed and i get no error.
If i change the datasource to a local datasource:
var seriesData = [{ Defect: "def1", DefectCount: 200 }, { Defect: "def2", DefectCount: 200}];
Then the pie is displayed.

I'm pretty sure it's an issue with my returned json response.
Please advice

0
Alexander Valchev
Telerik team
answered on 28 May 2012, 08:01 AM
Hi Yaniv,

I believe the problem is caused by the fact that you did not specified the root element that contains the data array.
var sharableDataSource = new kendo.data.DataSource({
    transport: {
        read: {
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "HttpHandler.aspx/Top5Defects",
            dataType: "json"
        }
    },
    schema: {
        data: "d" //the services return JSON in the following format { "d": <result> }. Specify how to get the result.
    }
});


Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Mentor Graphics
Top achievements
Rank 1
answered on 28 May 2012, 11:58 AM
Tnx , this solved the issue:
var sharableDataSource = new kendo.data.DataSource({
            transport:
            {
                read: {
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "HttpHandler.aspx/Top5Defects",
                    dataType: "json"
                }
            },
            error: function (e) {
                alert(e);
            },
            schema: {
                data: 'd'
            },
            columns: [ 
                        {
                            field: "Defect"                            
                        },
                        {
                            field: "DefectCount"                           
                        }
                     ]

        });       
Tags
Data Source
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Rosen
Telerik team
jeff moeller
Top achievements
Rank 1
Courouble Damien
Top achievements
Rank 1
Mentor Graphics
Top achievements
Rank 1
Alexander Valchev
Telerik team
Share this question
or