当前位置: 动力学知识库 > 问答 > 编程问答 >

oData v3 setting $format to application/json;odata=verbose doesn't convert to old json format

问题描述:

I'm working on a backbone.js app that GET the odata format from the controller:

 public IQueryable<ContactList> Get()

{

return dbContext.ContactsList.AsQueryable();

}

But the way I receive the data is in the following format

odata.count: "15504"

odata.metadata: "http://localhost:53341/odata/$metadata#Prescribers"

odata.nextLink: "http://localhost:53341/odata/Prescribers?$inlinecount=allpages&$format=application%2Fjson%3Bodata%3Dverbose

value: [,…]

Note the $format. Despite setting this up, it keeps sending me data in odata v3 format. I also tested it in Fiddler, but still the same result.

Am I doing something wrong? I'm trying to use the data for Backbone paginator https://github.com/backbone-paginator/backbone.paginator

网友答案:

I don't think webapi.odata v3 supports $format.

But you can try setting the accept header with application/json;...

If you want to use $format in the url, you can call "AddQueryStringMapping" to map $format, check this:

http://www.c-sharpcorner.com/UploadFile/2b481f/odata-feed-using-Asp-Net-web-api/

分享给朋友:
您可能感兴趣的文章:
随机阅读: