"No handler for Data"

Sep 22, 2012 at 4:11 AM


I am currently trying to use Data.js to access my Web Api through OData.

My model is called Rule and has 4 porperties, RuleKey (which is the id), Name, Attr, Value

I have a Controller called TestController in which, I have Get method which does this.

        public IQueryable<Rule> Get()
            List<Rule> rules = new List<Rule>();
            rules.Add(new Rule() { RuleKey = 1, Name = "Rule1", Attribute = "AAA", Operator = "is", Value = "SSS" });
            rules.Add(new Rule() { RuleKey = 2, Name = "Rule2", Attribute = "BBB", Operator = "in", Value = "7250, 7260" });
            rules.Add(new Rule() { RuleKey = 3, Name = "Rule3", Attribute = "CCCC", Operator = "is", Value = ".388" });

            return rules.AsQueryable();

On the client side, I am trying to do this.

           function (data) {
               var results = data.results;
           }, function (err) {
               var json = JSON.stringify(err);



This keeps giving me the following error.

"No handler for data"

Here is the request

GET http://localhost:41720/api/Test HTTP/1.1

Host: localhost:41720

Connection: keep-alive

MaxDataServiceVersion: 2.0

User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1

Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1

Referer: http://localhost:41720/

Accept-Encoding: gzip,deflate,sdch

Accept-Language: en-US,en;q=0.8

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3


 All I am trying to do here is a straight forward read. Why do I keep gettign this error. Am I missing some step.

 I did some research and found that we can try to get the metadata from the Api and send it along with the request.

Not sure if that would help. I was also not sure how to get metadata information from Web Api. I know we can use $metadata to get that info from a WCF service.

Please help. Let me know if you need any other information.



Sep 24, 2012 at 6:40 PM

Hi Krishna,

Can you share a trace of the response.  I'm interested to see if the response has the Content-Type header set to a value that indicates a valid OData mime type.


Alex Trigo.

Sep 24, 2012 at 7:33 PM

Hi Atrigo,

Thanks for the response.

I had to actually create a defaulthandler to get it to work.

 var jsonHandler = {
        read: function (response, context) {
            var contentType = response.headers["Content-Type"];
            if (contentType && contentType.indexOf("application/json") === 0) {
                response.data = response.body;
            } else {
                odata.defaultHandler.read(response, context);
        write: function (request, context) { }

Sep 24, 2012 at 8:40 PM

Hi Krishna,

   Out of curiosity, can you share a trace of the response? The fact that you had to that intrigues me.


Alex Trigo.

Oct 16, 2012 at 9:56 PM

Thanks, fixed my problem too!

Any reason for this handler not be deployed in the project?

Oct 24, 2012 at 2:50 AM

I wanted to add to this because I had this same issue today but I think I  found the cause.  I set a breakpoint where the jsonHandler is set and I noticed that the maxDataServiceVersion was set to 2.  I realized that my service was set to use version 3 and set it to max version 2 and the issue went away.


Its something to look at anyways.


Oct 24, 2012 at 7:42 PM

Hi Jason,

Great point, thanks!  DataJS 1.0.3 is an OData V2 client.  DataJS 1.1.0 which is beta now is the OData V3 client.  When this kind of issues happen, it is is very difficult to figure out what is going on without a trace of the response .


Alex Trigo.