WebApi and Angular Service Post - DataSourceRequest Sort/filtering not binding

3 posts, 0 answers
  1. Sam
    Sam avatar
    6 posts
    Member since:
    Jan 2015

    Posted 06 Aug 2015 Link to this post

    There seems to be several examples about web api and the data binder, however none of them seem to work well if I have a custom service that is posting the options.data object.  The Sort/Filters don't bind and are null.  

    Any help would be great or if there is a different way to easily post the DataSourceRequest via a service. 

    Here is a boiled down example:

    API Controller: 

     

    public DataSourceResult PageList(HttpRequestMessage requestMessage)
            {
                DataSourceResult result;
                
                var request = requestMessage.Content.ReadAsAsync<DataSourceRequest>().Result;
    // request.Sorts is null although the actual HTTP request was posted correctly.
                 
                
                    result = _someService.GetAllQ().ToDataSourceResult(request);
     
                return result;
            }

    Kendo Datasource Transport:

    transport: {
      read: function (options) {
        api.dosomething.pageList(options.data).then(function (data) {  //this is posted
          options.success(data);  
        });
    }​

  2. Sam
    Sam avatar
    6 posts
    Member since:
    Jan 2015

    Posted 06 Aug 2015 in reply to Sam Link to this post

    Just to clarify I've tried it with HttpRequestMessage and the Binder. Neither seem to work well in this case.
  3. Kendo UI is VS 2017 Ready
  4. Sam
    Sam avatar
    6 posts
    Member since:
    Jan 2015

    Posted 06 Aug 2015 Link to this post

    Okay, the binding only works on GET and not POST.  Lesson learned.
Back to Top