Skip to content
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

OData DeepInsert not binding correctly #1222

Open
JamezG12 opened this issue Apr 22, 2024 · 3 comments
Open

OData DeepInsert not binding correctly #1222

JamezG12 opened this issue Apr 22, 2024 · 3 comments
Assignees

Comments

@JamezG12
Copy link

JamezG12 commented Apr 22, 2024

Executing a DeepInsert on the ConnectedService generated client posts data to the server but doesn't bind the body to the parameter in the action.

Assemblies affected

Microsoft.AspNetCore.OData/8.2.5
Microsoft.AspnetCore.OpenApi/8.0.4
.Net 8

Reproduce steps

Issue deep insert to a POST endpoint

POST http://127.0.0.1:5282/v1/PayerAccounts HTTP/1.1
Host: 127.0.0.1:5282
OData-Version: 4.01
OData-MaxVersion: 4.01
Accept: application/json;odata.metadata=minimal
Accept-Charset: UTF-8
User-Agent: Microsoft.OData.Client/7.21.0
Connection: Keep-Alive
Content-Type: application/json;odata.metadata=minimal
Content-Length: 433

{"@type":"#OData.Api.Data.Entities.PayerAccount","ClientId":1,"Id":0,"IsDefault":true,"Reference":"console testing","PaymentSchedules":[{"AmountIncludingVat":1,"BankingReference":"ref"}]}

Expected result

The server accepts the payload and populates PayerAccount and it's PaymentSchedules.

Actual result

When the server receives the request, the body isn't bound and is null.

Additional detail

Changing the request headers from 4.01 to 4.0 causes the application to work as expected.

The following does not work, either omitting the OData-Version header or setting it to 4.0 works

POST http://127.0.0.1:5282/v1/PayerAccounts HTTP/1.1
Host: 127.0.0.1:5282
OData-Version: 4.01
OData-MaxVersion: 4.01
Accept: application/json;odata.metadata=minimal
Accept-Charset: UTF-8
User-Agent: Microsoft.OData.Client/7.21.0
Connection: Keep-Alive
Content-Type: application/json;odata.metadata=minimal
Content-Length: 433

{"@type":"#OData.Api.Data.Entities.PayerAccount","ClientId":1,"Id":0,"IsDefault":true,"Reference":"console testing","PaymentSchedules":[{"AmountIncludingVat":1,"BankingReference":"ref"}]}

This works

POST http://127.0.0.1:5282/v1/PayerAccounts HTTP/1.1
Host: 127.0.0.1:5282
OData-Version: 4.0
OData-MaxVersion: 4.01
Accept: application/json;odata.metadata=minimal
Accept-Charset: UTF-8
User-Agent: Microsoft.OData.Client/7.21.0
Connection: Keep-Alive
Content-Type: application/json;odata.metadata=minimal
Content-Length: 433

{"@type":"#OData.Api.Data.Entities.PayerAccount","ClientId":1,"Id":0,"IsDefault":true,"Reference":"console testing","PaymentSchedules":[{"AmountIncludingVat":1,"BankingReference":"ref"}]}
@JamezG12 JamezG12 changed the title OData Client DeepInsert not binding correctly OData DeepInsert not binding correctly Apr 23, 2024
@corranrogue9
Copy link
Contributor

corranrogue9 commented Apr 23, 2024

@JamezG12 Can you please share the controller method signature on the server side (and any implementation that you are comfortable sharing) so that we can investigate with a repro?

@corranrogue9 corranrogue9 transferred this issue from OData/odata.net Apr 23, 2024
@corranrogue9
Copy link
Contributor

@ElizabethOkerio do we expect support for deepinsert on both OData v4 and v4.01?

@ElizabethOkerio
Copy link
Contributor

ElizabethOkerio commented Apr 23, 2024

Yes this should be supported in v4.01 as well and users do not have to specify the OData-Version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants