Request URL is not in Odata format

2 posts, 0 answers
  1. Markus
    Markus avatar
    4 posts
    Member since:
    Apr 2013

    Posted 07 Apr 2013 Link to this post


    We have been struggling to implement a kendo-ui grid for several days consuming data from a WCF service proxy.  All of our data tests in Fiddler work correctly and if we hard code a request in our Get action in the controller we can see the service is working and our dataset it retrieved.  We think the issue is that the URL is request is not an Odata request. I have looked through to see if there is an Html helper to specify Odata in the index.chtml grid builder but have not found anything.  We are pretty close to giving up on Kendo-ui completely  I feel like this should be much easier to implement.

    @model IEnumerable<Application.ServiceProxy.CustomerDTO>
        .Columns(columns => {
            columns.Bound(c => c.customerID).Width(100);
            columns.Bound(c => c.name1).Width(100);
            columns.Bound(c => c.matchcode).Width(100);
            columns.Bound(c =>;
            columns.Bound(c => c.postalCode).Width(100);
        //.HtmlAttributes(new { style = "height:430px;" })
        .DataSource(dataSource => dataSource
            .Read(read => read.Action("Get", "Customer")   

    Customer Controller

    using System;
    using System.Collections.Generic;
    using System.Net.Http;
    using System.Web.Mvc;
    using Kendo.Mvc.UI;
    using Kendo.Mvc.Extensions;
    using BusinessLogic.Models;
    using System.Web;
    using System.Linq;
    using Newtonsoft.Json;
    using Application.ServiceProxy;
    using System.Web.Http;
    using System.Web.Http.OData.Query;
    using System.Web.Http.OData;
    namespace Application.Controllers
        public class CustomerController : Controller
            [Queryable(AllowedQueryOptions = AllowedQueryOptions.All)]
            public IEnumerable<ServiceProxy.CustomerDTO> Get()
                    var odataService = new Container(new Uri("http://localhost:8089/odata/"));
                var customer = odataService.Customer.Take(10);
                return customer.AsEnumerable();
            public ActionResult Index() {
                return View() ;

    BusinessLogic  customer controller (providing OData)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Web;
    using System.Net.Http;
    using System.Web.Http;
    using BusinessLogic.Models;
    using System.Web.Http.OData.Query;
    using System.Web.Http.OData;
    namespace BusinessLogic.Controllers
        //public class CustomerController : CPSGlobalAPIController
        public class CustomerController : EntitySetController<CustomerDTO, int>
            protected cpsGlobalEntities entity = new cpsGlobalEntities();
            #region mapper
            private IQueryable<CustomerDTO> mapCustomer()
                    from c in entity.customer
                    select new CustomerDTO()
                        customerID = c.customerID,
                        matchcode = c.matchcode,
                        salesOrganizationCompanyCode = c.salesOrganization.companyCode,
                        salesOrganizationID = c.salesOrganizationID,
                        salesOrganizationName =,
                        statusID = c.statusID,
                        statusPrefix = c.status.prefix,
                        statusTranslationKey = c.status.translationKey,
                        serviceLevelStatusID = c.serviceLevelStatusID,
                        serviceLevelPrefix = c.status1.prefix,
                        serviceLevelTranslationKey = c.status1.translationKey,
                        systemID = c.systemID,
                        dunsNumber = c.dunsNumber,
                        mediaIDLogo = c.mediaIDLogo,
                        salesOrganization = c.salesOrganization.companyCode,
                        inventoryManagerID = c.inventoryManager.inventoryManagerID,
                        inventoryManagerAddressID = c.inventoryManager.addressID,
                        customerExternalSystemID = c.customerExternalSystemID,
                        internationalGroup = c.internationalGroup,
                        division = c.division,
                        corporateID = c.corporateID,
                        #region duplicated items for improved list view
                        name1 = c.customerExternalSystem.address.name1,
                        postalCode = c.customerExternalSystem.address.postalCode,
                        city =,
                        stateCode = c.customerExternalSystem.address.state.stateCode,
                        countryCode =
            #region GET
            #region GET all
            public override IQueryable<CustomerDTO> Get()
                return mapCustomer().AsQueryable();
            #region GET by ID
            protected override CustomerDTO GetEntityByKey(int key)
                //return mapCustomer().FirstOrDefault(p => p.customerID == key);
                var cust = (from c in mapCustomer() where c.customerID == key select c).FirstOrDefault();
                if (cust.inventoryManagerAddressID != null)
                    AddressController adC = new AddressController();
                    cust.inventoryManagerAddressDTO = adC.Get((int)cust.inventoryManagerAddressID);
                if (cust.customerExternalSystemID != null)
                    CustomerExternalSystemController cesC = new CustomerExternalSystemController();
                    cust.customerExternalSystemDTO = cesC.Get((int)cust.customerExternalSystemID);
                if (cust == null)
                    throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.NotFound));
                return cust;
            #region POST
            protected override CustomerDTO CreateEntity(CustomerDTO customerDTO)
                var customer = new customer()
                    matchcode = customerDTO.matchcode,
                    salesOrganizationID = customerDTO.salesOrganizationID,
                    statusID = customerDTO.statusID,
                    serviceLevelStatusID = customerDTO.serviceLevelStatusID,
                    mediaIDLogo = customerDTO.mediaIDLogo,
                    systemID = customerDTO.systemID,
                    customerExternalSystemID = customerDTO.customerExternalSystemID,
                    internationalGroup = customerDTO.internationalGroup,
                    division = customerDTO.division,
                    corporateID = customerDTO.corporateID,
                    inventoryManagerID = customerDTO.inventoryManagerID,
                    dunsNumber = customerDTO.dunsNumber
                return GetEntityByKey(customer.customerID);
            protected override int GetKey(CustomerDTO customer)
                return customer.customerID;
            #region Put
            protected override CustomerDTO UpdateEntity(int key, CustomerDTO customerDTO)
                var originalCustomer = entity.customer.Find(key);
                originalCustomer.matchcode = customerDTO.matchcode;
                originalCustomer.salesOrganizationID = customerDTO.salesOrganizationID;
                originalCustomer.statusID = customerDTO.statusID;
                originalCustomer.serviceLevelStatusID = customerDTO.serviceLevelStatusID;
                originalCustomer.mediaIDLogo = customerDTO.mediaIDLogo;
                originalCustomer.systemID = customerDTO.systemID;
                originalCustomer.customerExternalSystemID = customerDTO.customerExternalSystemID;
                originalCustomer.inventoryManagerID = customerDTO.inventoryManagerID;
                originalCustomer.dunsNumber = customerDTO.dunsNumber;
                originalCustomer.internationalGroup = customerDTO.internationalGroup;
                originalCustomer.division = customerDTO.division;
                originalCustomer.corporateID = customerDTO.corporateID;
                return GetEntityByKey(key);
            #region PATCH
            #region DELETE
            public override void Delete([FromODataUri] int key)
                var customer = entity.customer.Find(key);
                if (customer == null)
                    throw new HttpResponseException(HttpStatusCode.NotFound);

  2. Atanas Korchev
    Atanas Korchev avatar
    8462 posts

    Posted 08 Apr 2013 Link to this post

    Hello Markus,

    Your action method needs to return data in the format expected by the grid. You can find more info here:

    Basically you need to call the ToDataSourceResult extension method:

    public IEnumerable<ServiceProxy.CustomerDTO> Get([DataSourceRequest] DataSourceRequest request)
                    var odataService = new Container(newUri("http://localhost:8089/odata/"));
                var customer = odataService.Customer.Take(10);
                return customer.ToDataSourceResult(request);

    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!
Back to Top