I think this may be a bug, but I'm not sure.
Basically I'm trying to submit an OData batch operation, but it's not calling my controller action. There are three components involved in this:
1) Web API OData
3) BreezeJS (which uses datajs for client OData support)
BreezeJS by default generates the batch sub-operations (e.g. POST/PUT) using a URI relative to the odata route prefix. For example, for a service hosted at
for a batch that includes one insert sends the following multipart requerst:
Content-Type: multipart/mixed; boundary=changeset_f02f-91e5-10d3
POST Topics HTTP/1.1
Accept: application/atomsvc+xml;q=0.8, application/json;odata=fullmetadata;q=0.7, application/json;q=0.5, */*;q=0.1
If I change the POST URI in Fiddler to be absolute, it works. First I thought this is a problem in BreezeJS itself, but when I read the OData spec it doesn't seem to be very clear on whether the batch sub-operation URIs should be relative or absolute.
A similar issue was first repoted in
Oh and I'm using CORS btw (the Web API is in a different application from the client app), but I don't think this is related to the problem.
I had to dig into the ASP.NET Web API OData source code to see if relative URIs are supported. I found that it actually tries to build the operation URI by combining the OData route base URI with the operation relative URI, but something interesting happens
deep down in one of the ODataLib methods (in the Microsoft.Data.OData assemblly):
internal static Uri UriToAbsoluteUri(Uri baseUri, Uri relativeUri)
return new Uri(baseUri, relativeUri);
The problem is that the baseUri in this case is
and the relativeUri is
. Without a trailing slash in the baseUri, this will result in the following output Uri
. If there was a trailing slash we would get the desired result
Now I'm not sure who's responsibility is to fix this:
1) BreezeJS should use absolute URIs in sub-operations, e.g.
2) Web API OData should use a baseUri with a trailing slash, so that it can be combined properly with relativeUris
3) ODataLib should be smart about combining baseUris and relativeUris so as to avoid the above trailing slash issue
Or it could be something else that I"m not aware of. I just thought I'd post this in a discussion thread first to gather feedback before submitting a bug report.