Web API ODATA - posting embedded entity - different behavior betweeb json and atom+xml

Topics: ASP.NET Web API
Jun 17, 2013 at 9:47 AM
Hi!

We have an ODATA endpoint for posting 2 resource types:
  1. Payment
  2. EnrollSourcePayment
EnrollSourcePayment can contain embedded Payment inside it.

We have noticed confusing behavior when posting entitties in json and atom/xml format.

When using json:
  1. We POST EnrollSourcePayment with embedded Payment to server.
  2. Embedded payment is deserialized successfully on server side.
  3. When we GET the previously created EnrollSourcePayment a link to the corresponding Payment is returned instead of embedded entity.
When using atom+xml
  1. We POST EnrollSourcePayment with embedded Payment to server.
  2. Embedded payment is NOT deserialized successfully on server side, it comes as null after the deserialization.
When we remove Payment from ODataModelBuilder metadata (do not expose Payment as separate entity), everything works fine with atom+xml and we can POST an embedded entity.

Different behavior between formatters seems rather strange.

Please advise.

Thanks,
Aliaksandr.