Friday 15 June 2012

asp.net web api - Breeze batch request with ODataConventionModelBuilder -



asp.net web api - Breeze batch request with ODataConventionModelBuilder -

i seek implement breeze webapi odata webservice.

on server side utilize odataconventionmodelbuilder , defaultodatabatchhandler:

var builder = new odataconventionmodelbuilder(); builder.entityset<mymodeltype>("mymodeltypes"); builder.namespace = typeof(mymodeltype).namespace; config.routes.mapodataroute( routename: "odataroute", routeprefix: "api", model: builder.getedmmodel(), batchhandler: new defaultodatabatchhandler(globalconfiguration.defaultserver));

on client side utilize webapiodata:

breeze.config.initializeadapterinstance('dataservice', 'webapiodata', true);

service name /api, , utilize server side metadata:

var dataservice = new breeze.dataservice({ servicename: '/api', hasservermetadata: true }); var manager = new breeze.entitymanager({ dataservice: dataservice });

if seek phone call entitymanager.savechanges() correctly calls /api/$batch. changeset tries post /api/mymodeltypes:

--batch_389a-6d15-37bd content-type: multipart/mixed; boundary=changeset_a807-ab31-a36a --changeset_a807-ab31-a36a content-type: application/http content-transfer-encoding: binary post api/mymodeltypes http/1.1 content-id: 1 dataserviceversion: 2.0 accept: application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, */*;q=0.1 content-type: application/json maxdataserviceversion: 3.0 {"id":-1,"text":"foo"} --changeset_a807-ab31-a36a-- --batch_389a-6d15-37bd--

this results changeset in phone call http://myhost/api/api/mymodeltypes instead of http://myhost/api/mymodeltypes:

--batchresponse_4d3988b4-10e6-4df4-bae3-a1fa034a065c content-type: multipart/mixed; boundary=changesetresponse_b1df8cf5-8450-43f7-9eda- 5dc6bfdb7554 --changesetresponse_b1df8cf5-8450-43f7-9eda-5dc6bfdb7554 content-type: application/http content-transfer-encoding: binary http/1.1 404 not found content-id: 1 content-type: application/json; charset=utf-8 {"message":"no http resource found matches request uri 'http://myhost/api/api/mymodeltypes'."} --changesetresponse_b1df8cf5-8450-43f7-9eda-5dc6bfdb7554-- --batchresponse_4d3988b4-10e6-4df4-bae3-a1fa034a065c--

what need alter create breeze right links in batch request?

it seems error introduced between version 5.2.2 , 5.3.1 in microsoft.aspnet.webapi.odata , breezejs not adopted yet accordingly:

odata issue after updating microsoft.aspnet.webapi.odata 5.3.x

i've added issue breezejs: https://github.com/breeze/breeze.js/issues/42

asp.net-web-api odata breeze

No comments:

Post a Comment