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

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

2 Answers 64 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 06 Aug 2015, 08:46 PM

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 Answers, 1 is accepted

Sort by
0
Sam
Top achievements
Rank 1
answered on 06 Aug 2015, 08:53 PM
Just to clarify I've tried it with HttpRequestMessage and the Binder. Neither seem to work well in this case.
0
Sam
Top achievements
Rank 1
answered on 06 Aug 2015, 09:23 PM
Okay, the binding only works on GET and not POST.  Lesson learned.
Tags
Data Source
Asked by
Sam
Top achievements
Rank 1
Answers by
Sam
Top achievements
Rank 1
Share this question
or