New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable updating top-level properties to null #645

Closed
TomDu opened this Issue Jul 22, 2016 · 13 comments

Comments

Projects
None yet
6 participants
@TomDu
Contributor

TomDu commented Jul 22, 2016

Re-enable updating top-level properties to null after "odata.null" is removed (#630).

@TomDu TomDu added this to the 7.1 milestone Aug 3, 2016

@robward-ms robward-ms added the P2 label May 26, 2017

@maubin-kl

This comment has been minimized.

maubin-kl commented Sep 11, 2017

Is there an ETA on this? This is a breaking change from version prior to 6.0.0.

We currently cannot update to 6.0.0 because we have custom actions that returns a null value. We do expect to receive a null value on the client side and instead it is now an exception.

@maubin-kl

This comment has been minimized.

maubin-kl commented Sep 14, 2017

@lpperras

This comment has been minimized.

lpperras commented Feb 8, 2018

@TomDu Any news on this?

@robward-ms robward-ms self-assigned this Feb 21, 2018

@robward-ms

This comment has been minimized.

Contributor

robward-ms commented Feb 21, 2018

The scenario is not supported per the language of the spec:

11.2.3 Requesting Individual Properties
To retrieve an individual property, the client issues a GET request to the property URL. The property URL is the entity read URL with "/" and the property name appended.
For complex typed properties, the path can be further extended with the name of an individual property of the complex type.
See [OData‑URL] for details.
If the property is single-valued and has the null value, the service responds with 204 No Content.
If the property is not available, for example due to permissions, the service responds with 404 Not Found.

So the right thing to do is return 204.

However, I've made a change to the library to enable back-compat behavior via a writer validation that is on by default. When turned off, the exception is no longer throws an "value":null is written. Not that thus behavior is not compliant with the latest protocol. See #1093 for the change.

@robward-ms

This comment has been minimized.

Contributor

robward-ms commented Mar 5, 2018

Add a change to allow the odata@null to be written under 6.x compatibility mode and read unconditionally, see #1093

@robward-ms robward-ms added fixed and removed in-progress labels Mar 5, 2018

@maubin-kl

This comment has been minimized.

maubin-kl commented Mar 27, 2018

@robward-ms Thanks for making the fix. I understand that this is not in the spec but in order to not break our existing clients integration we still need to support that on our end.

I've reviewed the PR and the changes that you've made. However it's not really apparent to me how can I change the behaviour in my application.

Where from my WebApiConfig can I set the ODataLibraryCompatibility to version 6.xxxx?

@robward-ms

This comment has been minimized.

Contributor

robward-ms commented Mar 27, 2018

@maubin-kl - The writer settings would need to be injected into the service container. This shows where in WebApi the writer settings are read.

You can read more about ODL and dependency injection here.

@maubin-kl

This comment has been minimized.

maubin-kl commented Apr 17, 2018

@robward-ms

I went through the documentation that you provided me. I was able to build my own container and add a modified ODataMessageWriterSettings that sets the LibraryCompatibility to Version6.

However I haven't figured out how to pass it to ODataLib. It's specified that it can be sent through ODataMessageReader/ODataMessageWriter or ODataUriParser but there's no example provided and I couldn't find more information.

I was able to change the setting by manually doing the following code in one of my action

var settings = (ODataMessageWriterSettings)this.Request.GetRequestContainer().GetService(typeof(ODataMessageWriterSettings));
settings.LibraryCompatibility = ODataLibraryCompatibility.Version6;

However I have the problem at large and doing so would be very inefficient. Could you provide me the information I seem to be missing or point me in a direction for the answer? Please note I use OData6.0.0 at the moment as one of my package has a reference to it and prevent me from targeting 7.0.0 at the moment. OData.Core is 7.4.3.20321.

Thanks

@robward-ms

This comment has been minimized.

Contributor

robward-ms commented Apr 18, 2018

@maubin-kl - So you are using OData.Core 7.4.3 with OData WebApi 6.0.0 and are looking for details on how to inject the setting via WebApi?

I think @biaol-odata had recently worked in that area. @biaol-odata -can you comment on this?

@maubin-kl

This comment has been minimized.

maubin-kl commented Apr 18, 2018

@robward-ms That is correct.

@maubin-kl

This comment has been minimized.

maubin-kl commented May 14, 2018

@robward-ms @biaol-odata

Hey guys, I still have no idea how to change the settings as mentioned above. This is the only blocking issue remaining before we can release a new version of our application.

Help would be really appreciated. Thanks

@biaol-odata

This comment has been minimized.

Member

biaol-odata commented May 14, 2018

On WebApi 6.x, client can customize the service container using a customized configureAction for MapODataServiceRoute method.
https://github.com/OData/WebApi/blob/maintenance-6.x/src/System.Web.OData/Extensions/HttpConfigurationExtensions.cs#L509
The method could be invoked from your client code during Web layer start up, such as inside updateConfiguration method.

In configureAction, you can specify build => builder.AddServicePrototype(new ODataMessageWriterSettings
{
EnableMessageStreamDisposal = false,
MessageQuotas = new ODataMessageQuotas { MaxReceivedMessageSize = Int64.MaxValue },
LibraryCompatibility = ODataLibraryCompatibility.Version6
});
to use the Version6 compatibility. (Please adjust it properly if you already have a customized writer setting).

@maubin-kl

This comment has been minimized.

maubin-kl commented May 15, 2018

Thanks @biaol-odata. It works.

Thanks everyone for your support.

@mikepizzo mikepizzo closed this Jun 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment