invalid label "d" : {

11 posts, 1 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 10 Dec 2011 Link to this post

    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?
  2. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 10 Dec 2011 Link to this post

    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?
  3. Kendo UI is VS 2017 Ready
  4. Answer
    Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 13 Dec 2011 Link to this post

    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!
  5. jeff moeller
    jeff moeller avatar
    2 posts
    Member since:
    Jan 2010

    Posted 06 Jan 2012 Link to this post

    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
  6. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 09 Jan 2012 Link to this post

    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!
  7. jeff moeller
    jeff moeller avatar
    2 posts
    Member since:
    Jan 2010

    Posted 09 Jan 2012 Link to this post

    I tried both of these:



    and still got:

    "Query options $orderby, $inlinecount, $skip and $top cannot be applied to the requested resource."
  8. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 10 Jan 2012 Link to this post

    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!
  9. Courouble Damien
    Courouble Damien avatar
    54 posts
    Member since:
    Aug 2009

    Posted 17 May 2012 Link to this post

    Any updates on that issue ? 

    Thanks
  10. Mentor Graphics
    Mentor Graphics avatar
    12 posts
    Member since:
    Dec 2011

    Posted 27 May 2012 Link to this post

    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

  11. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2877 posts

    Posted 28 May 2012 Link to this post

    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!
  12. Mentor Graphics
    Mentor Graphics avatar
    12 posts
    Member since:
    Dec 2011

    Posted 28 May 2012 Link to this post

    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"                           
                            }
                         ]

            });       
Back to Top
Kendo UI is VS 2017 Ready