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

Enable POST of lists of items to collections #135

Open
davidmoten opened this issue May 1, 2021 · 4 comments
Open

Enable POST of lists of items to collections #135

davidmoten opened this issue May 1, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@davidmoten
Copy link
Owner

davidmoten commented May 1, 2021

As mentioned in #103, would be nice to be able to post lists rather than just single items:

client.companies().purchaseInvoices("123").purchaseInvoiceLines().post(list);

In fact it seems that some paths in Microsoft OData APIs (like Dynamics CRM) accept a post of a purchaseInvoice with multiple lines inline (discussed in #103).

@davidmoten davidmoten added the enhancement New feature or request label May 1, 2021
@davidmoten
Copy link
Owner Author

I'm not sure from browsing the specification under what circumstances (in terms of the service metadata) the service would accept inline collections. If anybody figures it out let me know!

@davidmoten
Copy link
Owner Author

@mbasboll I'm looking at having fields for all navigational properties as well to enable the building of a PurchaseInvoice with all related PurchaseInvoiceLines inline.

@mbasboll
Copy link

Just tying back to #103, using postman, I am successfully able to perform a post command to this url in my Business Central sandbox environment:

https://api.businesscentral.dynamics.com/v2.0/*environmentid*/sandbox/api/v2.0/companies(*companyid*)/purchaseInvoices?$expand=purchaseInvoiceLines

with this json body:

{
"number": "125",
"vendorNumber": "SHOMAK",
"purchaseInvoiceLines": [
{
"itemId": "bfc03c90-2fe0-47fc-9f51-a4d2c605944c",
"description": "Some custom material",
"quantity": 5,
"dimensionSetLines": [
{
"code": "DIVISION",
"valueCode": "RES"
},
{
"code": "REGION",
"valueCode": "CAL"
},
{
"code": "LINEOFB",
"valueCode": "DI"
},
{
"code": "BUSALL",
"valueCode": "PRO"
}
]
},
{
"itemId": "bfc03c90-2fe0-47fc-9f51-a4d2c605944c",
"description": "Some more custom material",
"quantity": 10,
"dimensionSetLines": [
{
"code": "DIVISION",
"valueCode": "RES"
},
{
"code": "REGION",
"valueCode": "CAL"
},
{
"code": "LINEOFB",
"valueCode": "DI"
},
{
"code": "BUSALL",
"valueCode": "PRO"
}
]
}
]
}

This has nested collections. PurchaseInvoice has an inline collection of PurchaseInvoiceLines and then PurchaseInvoiceLine has a collection of dimensionSetLines.

Would be extremely nice to be able to go this deep with PurchaseInvoice and SalesInvoice.

Just let me know if I can provide any more information from my test environment.

@davidmoten
Copy link
Owner Author

I'm still pondering this change. I see that NavigationPropertys have a ContainsTarget field. If ContainsTarget is true then the referred item is contained within the entity so makes more sense a post with an inline collection might work. As far as I can tell there is no other metadata that makes it clear that this is possible.

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

No branches or pull requests

2 participants