draxtor
draxtor

Reputation: 104

Odata Web Api 2.2 $batch operation fails

I'm trying to create $batch request with JavaScript for Odata Web API 2.2 v4 service. I have working patch, post, get and delete on the controller. I've enabled batchHandler with new DefaultOdataBatchHandler in webapiconfig. I tried datajs library (which seems to work with v3 only) and batchjs in both cases I'm receiveng following error:

--batchresponse_bc02e191-d7ed-4a0d-848d-5aec3fabe7a8
Content-Type: application/http
Content-Transfer-Encoding: binary

HTTP/1.1 404 Not Found
Content-Type: application/json; charset=utf-8

{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:51553/odata/contact'.","MessageDetail":"No route data was found for this request."}
--batchresponse_bc02e191-d7ed-4a0d-848d-5aec3fabe7a8--

But this route (http://localhost:51553/odata/contact) exists and it is working when I open it in browser.

Here is my request (recreated from http://www.odata.org/documentation/odata-version-3-0/batch-processing/):

POST http://localhost:51553/odata/$batch

Content-Length:230
Content-Type:multipart/mixed; boundary="batch_36522ad7-fc75-4b56-8c71-56071383e77b"

--batch_36522ad7-fc75-4b56-8c71-56071383e77b
Content-Type: application/http
Content-Transfer-Encoding: binary

GET /odata/contact HTTP/1.1
Host: localhost:51553

--batch_36522ad7-fc75-4b56-8c71-56071383e77b--

Or if someone knows a good example of v4 $batch with JavaScript that would be great.

Thanks

Update

I made some progress. I rewrite some parts of batchjs plugin (https://github.com/volpav/batchjs), because number and position of new lines are important. So it's working now in my small sample project. In my main project it's not working 'cause I'm using HttpContext.Current in some modules which exists in main call odata/$batch, but not in inline (batch) ones. It seems like multithreading issue now.

Upvotes: 1

Views: 362

Answers (0)

Related Questions