Support PATCH to a complex type. #135

Closed
LianwMS opened this Issue Jan 12, 2015 · 19 comments

Comments

Projects
None yet
@LianwMS
Contributor

LianwMS commented Jan 12, 2015

Now we the Delta class only supports Entity type, but the protocol also
supports PATCH to a complex type:

11.4.9.3 Update a Complex Type

A successful PATCH request to the edit URL for a complex typed property updates that property. The request body MUST contain a single valid representation for the target complex type.
The service MUST directly modify only those properties of the complex type specified in the payload of the PATCH request.

Work Item Details

Original CodePlex Issue: Issue 2066
Status: Proposed
Reason Closed: Unassigned
Assigned to: Unassigned
Reported on: Jul 16, 2014 at 4:02 AM
Reported by: jinfutan
Updated on: Oct 20, 2014 at 7:28 PM
Updated by: abatishchev

@LianwMS

This comment has been minimized.

Show comment
Hide comment
@LianwMS

LianwMS Jan 12, 2015

Contributor

On 2014-10-14 21:20:55 UTC, skotapati commented:

Just wondering when will this feature be available in WebAPI/OData?

Contributor

LianwMS commented Jan 12, 2015

On 2014-10-14 21:20:55 UTC, skotapati commented:

Just wondering when will this feature be available in WebAPI/OData?

@LianwMS LianwMS added this to the vNext milestone Jan 12, 2015

@sammym1982

This comment has been minimized.

Show comment
Hide comment
@sammym1982

sammym1982 Mar 13, 2015

Is this being worked upon?

Is this being worked upon?

@Tornhoof

This comment has been minimized.

Show comment
Hide comment
@Tornhoof

Tornhoof Jun 5, 2015

+1 on this. Using complex types simplifies the data models, especially for nested structures

Tornhoof commented Jun 5, 2015

+1 on this. Using complex types simplifies the data models, especially for nested structures

@ashelley

This comment has been minimized.

Show comment
Hide comment
@ashelley

ashelley Nov 13, 2015

+1 on this. Not being able to patch nested objects is a big limitation.

+1 on this. Not being able to patch nested objects is a big limitation.

@zizzex

This comment has been minimized.

Show comment
Hide comment
@zizzex

zizzex Nov 19, 2015

Without nested objects this feature is unfortunately almost useless.
Is there any prevision of a possible availability date? Thanks.

zizzex commented Nov 19, 2015

Without nested objects this feature is unfortunately almost useless.
Is there any prevision of a possible availability date? Thanks.

@RavindraBarapatre

This comment has been minimized.

Show comment
Hide comment
@RavindraBarapatre

RavindraBarapatre Dec 23, 2015

Below is my Address entity, it has PostalAddress as nested entity, I am trying to do patch update.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated",
"PostalAddress": {
"Id": "9bd27f41-e093-46ce-8d51-10ba7e2e3e13",
"PoBox": "12121",
"PostalCode": "12121"
}
}
when I debug odata service I received Delta patch = null.

If I pass simple object it works.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated"
}

is it because Delta not support nested object or Patch in Odata service is not supporting it.

Below is my Address entity, it has PostalAddress as nested entity, I am trying to do patch update.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated",
"PostalAddress": {
"Id": "9bd27f41-e093-46ce-8d51-10ba7e2e3e13",
"PoBox": "12121",
"PostalCode": "12121"
}
}
when I debug odata service I received Delta patch = null.

If I pass simple object it works.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated"
}

is it because Delta not support nested object or Patch in Odata service is not supporting it.

@shaungrech

This comment has been minimized.

Show comment
Hide comment
@shaungrech

shaungrech Dec 23, 2015

Hi,

As far as I know at the moment OData Web API does not support Patch within
nested objects.

Shaun

On Wed, Dec 23, 2015 at 1:29 PM, RavindraBarapatre <notifications@github.com

wrote:

Below is my Address entity, it has PostalAddress as nested entity, I am
trying to do patch update.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated",
"PostalAddress": {
"Id": "9bd27f41-e093-46ce-8d51-10ba7e2e3e13",
"PoBox": "12121",
"PostalCode": "12121"
}
}
when I debug odata service I received Delta patch = null.

If I pass simple object it works.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated"
}

is it because Delta not support nested object or Patch in Odata service is
not supporting it.


Reply to this email directly or view it on GitHub
#135 (comment).

Regards,

Shaun Grech Co-Founder, Incredible Web / Bum a Lift
79886164
shaun.grech@incredible-web.com
www.incredible-web.com
www.bumalift.com http://www.incredible-web.com/

Hi,

As far as I know at the moment OData Web API does not support Patch within
nested objects.

Shaun

On Wed, Dec 23, 2015 at 1:29 PM, RavindraBarapatre <notifications@github.com

wrote:

Below is my Address entity, it has PostalAddress as nested entity, I am
trying to do patch update.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated",
"PostalAddress": {
"Id": "9bd27f41-e093-46ce-8d51-10ba7e2e3e13",
"PoBox": "12121",
"PostalCode": "12121"
}
}
when I debug odata service I received Delta patch = null.

If I pass simple object it works.
{
"CareOf": "Updated",
"BehalfOf": "BehalfOf updated"
}

is it because Delta not support nested object or Patch in Odata service is
not supporting it.


Reply to this email directly or view it on GitHub
#135 (comment).

Regards,

Shaun Grech Co-Founder, Incredible Web / Bum a Lift
79886164
shaun.grech@incredible-web.com
www.incredible-web.com
www.bumalift.com http://www.incredible-web.com/

@RavindraBarapatre

This comment has been minimized.

Show comment
Hide comment
@RavindraBarapatre

RavindraBarapatre Dec 23, 2015

Ohhh .. :(
is there any workaround?

Ohhh .. :(
is there any workaround?

@sgankum

This comment has been minimized.

Show comment
Hide comment
@sgankum

sgankum Dec 23, 2015

without supporting nested objects, i believe this is not an useful one.
Kindly let us know the workaround for this

sgankum commented Dec 23, 2015

without supporting nested objects, i believe this is not an useful one.
Kindly let us know the workaround for this

@xuzhg xuzhg modified the milestones: v5.9, v5.8 Jan 6, 2016

@lelong37

This comment has been minimized.

Show comment
Hide comment

+100

xuzhg added a commit to xuzhg/WebApi that referenced this issue Feb 1, 2016

@xuzhg

This comment has been minimized.

Show comment
Hide comment
@xuzhg

xuzhg Feb 1, 2016

Member

Dear customers, Would you please help me try the [PR]#623 and give me some feedback?

I would like to put it into 5.9 beta so customers can use it from nightly build. Thanks.

Member

xuzhg commented Feb 1, 2016

Dear customers, Would you please help me try the [PR]#623 and give me some feedback?

I would like to put it into 5.9 beta so customers can use it from nightly build. Thanks.

xuzhg added a commit to xuzhg/WebApi that referenced this issue Feb 3, 2016

xuzhg added a commit that referenced this issue Feb 3, 2016

@xuzhg

This comment has been minimized.

Show comment
Hide comment
@xuzhg

xuzhg Feb 3, 2016

Member

I merged my fix. Anyone who try it and find any issue, please reopen it or file a new issue for us. Thanks in advance.

Member

xuzhg commented Feb 3, 2016

I merged my fix. Anyone who try it and find any issue, please reopen it or file a new issue for us. Thanks in advance.

@xuzhg xuzhg closed this Feb 3, 2016

xuzhg added a commit to xuzhg/WebApi that referenced this issue Mar 4, 2016

@egbertn

This comment has been minimized.

Show comment
Hide comment
@egbertn

egbertn Mar 20, 2017

package id="Microsoft.OData.Core" version="7.0.0" targetFramework="net462"
package id="Microsoft.OData.Edm" version="7.0.0" targetFramework="net462"

These packages are totally different compared with 5.9.x
Will the patch be fixed in those as well?

egbertn commented Mar 20, 2017

package id="Microsoft.OData.Core" version="7.0.0" targetFramework="net462"
package id="Microsoft.OData.Edm" version="7.0.0" targetFramework="net462"

These packages are totally different compared with 5.9.x
Will the patch be fixed in those as well?

@bkwdesign

This comment has been minimized.

Show comment
Hide comment
@bkwdesign

bkwdesign Mar 20, 2017

I can't even get my odata v4 api controller to support PATCHing of my main entity

Have no idea how to get an ajax PATCH request to work.. always get a null at my controller's 'delta' parameter

NuGet packages:
id="Microsoft.AspNet.OData" version="6.0.0"
id="Microsoft.OData.Core" version="7.0.0"
id="Microsoft.OData.Edm" version="7.0.0"

I can't even get my odata v4 api controller to support PATCHing of my main entity

Have no idea how to get an ajax PATCH request to work.. always get a null at my controller's 'delta' parameter

NuGet packages:
id="Microsoft.AspNet.OData" version="6.0.0"
id="Microsoft.OData.Core" version="7.0.0"
id="Microsoft.OData.Edm" version="7.0.0"

@egbertn

This comment has been minimized.

Show comment
Hide comment
@egbertn

egbertn Mar 20, 2017

Important is the body and the URL syntax e.g.

public async Task<IHttpActionResult> Patch(Guid key, [DeltaBody] Data.OData.Delta<company> delta)

Second, I copied Delta from the Github 5.9 libraries, that are more recent than the 7.0 libraries and 'renamed' the namespace so I got it working, more or less.
DeltaBody is my own attribute
to intercept the raw message and I use NewtonSoft to deserialize the message, so the complex type will be patched too! This has side effects, because OData serialisation is simply not the same, but it works, in my case.
drop a message to my profile, if you want the source for the 'delta workaround'.

egbertn commented Mar 20, 2017

Important is the body and the URL syntax e.g.

public async Task<IHttpActionResult> Patch(Guid key, [DeltaBody] Data.OData.Delta<company> delta)

Second, I copied Delta from the Github 5.9 libraries, that are more recent than the 7.0 libraries and 'renamed' the namespace so I got it working, more or less.
DeltaBody is my own attribute
to intercept the raw message and I use NewtonSoft to deserialize the message, so the complex type will be patched too! This has side effects, because OData serialisation is simply not the same, but it works, in my case.
drop a message to my profile, if you want the source for the 'delta workaround'.

@olumyde777

This comment has been minimized.

Show comment
Hide comment
@olumyde777

olumyde777 Apr 20, 2018

Hi Egbertn,
Please I need the source code for the 'delta workaround'.
My email address is olumyde77@yahoo.com
Thanks

Hi Egbertn,
Please I need the source code for the 'delta workaround'.
My email address is olumyde77@yahoo.com
Thanks

@olumyde777

This comment has been minimized.

Show comment
Hide comment
@olumyde777

olumyde777 Apr 21, 2018

Hi Egbertn,
Thanks for the source code.
It worked for me. You have really helped to solve a problem I had been on it for almost 5 months.
Thanks once again.

Hi Egbertn,
Thanks for the source code.
It worked for me. You have really helped to solve a problem I had been on it for almost 5 months.
Thanks once again.

@bkwdesign

This comment has been minimized.

Show comment
Hide comment
@bkwdesign

bkwdesign Apr 21, 2018

Yes, we are currently using it in all our projects for several months now- I've put your code into a standalone assembly that I can reference in each WebAPI project

Yes, we are currently using it in all our projects for several months now- I've put your code into a standalone assembly that I can reference in each WebAPI project

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