Comments (17)
David,
Yes, this is excellent! I am now able to build my client with the new option:
private MicrosoftClientBuilder createBuilder() {
Creator creator = context -> {
try {
return b.serviceCls.getConstructor(Context.class).newInstance(context);
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException
| InvocationTargetException | NoSuchMethodException | SecurityException e) {
throw new ClientException(e);
}
};
return MicrosoftClientBuilder //
.baseUrl(b.baseUrl.get()) //
.creator(creator) //
.addSchema(SchemaInfo.INSTANCE) //
.pathStyle(PathStyle.IDENTIFIERS_IN_ROUND_BRACKETS) //
.build();
}
Many thanks for this,
Morten
from odata-client.
Sorry, got distracted. Release 0.1.51 is on Maven Central now with the discussed enhancement.
from odata-client.
Can you post the service metadata? I need to clarify what is a function and what is not. Can you also show me how you built your client? The other Microsoft services use this option;
You may want PathStyle.IDENTIFIERS_IN_ROUND_BRACKETS
.
from odata-client.
I have attached the metadata file here. Looks reasonable that I might need to change to PathStyle.IDENTIFIERS_IN_ROUND_BRACKETS
Can I just make the change in: odata-client/odata-client-microsoft-client-builder/src/main/java/com/github/davidmoten/microsoft/client/builder/MicrosoftClientBuilder.java
Line 520 in b3b46c8
I would be happy to show you how I built my client but I am new to github so I am not quite sure how I can share it.
Many thanks for your help so far.
from odata-client.
By all means give it a shot. If required I can make that configurable publicly in the client builder.
from odata-client.
Things look very good! A made the change from:
Path basePath = new Path(baseUrl, PathStyle.IDENTIFIERS_AS_SEGMENTS);
to
Path basePath = new Path(baseUrl, PathStyle.IDENTIFIERS_IN_ROUND_BRACKETS);
My preliminary testing has been successful and I have not encountered any issues. I think it would be very helpful if this was configurable.
Thanks again for this.
from odata-client.
I've added support in MicrosoftClientBuilder in PR #106 which has been merged. Let me know if it suits and I'll build the next release.
from odata-client.
Good to hear! I'll build the next release with that change shortly.
from odata-client.
Good to hear! I'll build the next release with that change shortly.
Hi David.
I would like to ask when this fix will be released and available via Maven Central?
from odata-client.
Hello David,
Updated to 0.1.51 and things are looking good. I am able to do gets(), posts(), and deletes() on purchase invoice documents in Business Central. Just running into the following error in RequestHelpler.java, trying to do a patch() to update a purchase invoice:
com.github.davidmoten.odata.client.ClientException: responseCode=400 from url=https://api.businesscentral.dynamics.com/v2.0//Sandbox/ODataV4/Company('PML')/PurchaseInvoice(Document_Type%3D'Invoice'%2CNo%3D'IPI-0561282'), expectedResponseCode in [200, 299], message=
{"error":{"code":"BadRequest_InvalidToken","message":"Could not validate the client concurrency token required by the service. Please provide a valid token in the client request. CorrelationId: 41403538-77d3-4eed-ac4a-84b730dc6310."}}
at com.github.davidmoten.odata.client.internal.RequestHelper.checkResponseCode(RequestHelper.java:88)
at com.github.davidmoten.odata.client.internal.RequestHelper.checkResponseCode(RequestHelper.java:94)
at com.github.davidmoten.odata.client.internal.RequestHelper.patchOrPut(RequestHelper.java:257)
at com.github.davidmoten.odata.client.internal.RequestHelper.patch(RequestHelper.java:196)
at com.github.davidmoten.odata.client.EntityRequest.patch(EntityRequest.java:33)
at com.github.davidmoten.odata.client.EntityRequestOptionsBuilder.patch(EntityRequestOptionsBuilder.java:94)
at com.github.davidmoten.odata.client.EntityRequest.patch(EntityRequest.java:49)
Looks like it could be an authentication issue in my code but I noticed some TODO statements in your code. Can you tell me if the patch function is working?
Many thanks,
Morten
from odata-client.
This looks relevant:
from odata-client.
David,
Would you know how I could use your library to perform deep inserts in Business Central? I have successfully posted the following json payload in postman to https://api.businesscentral.dynamics.com/v2.0/[environment id]/sandbox/api/v2.0/companies([company id])/purchaseInvoices
{
"number": "1234",
"vendorNumber": "VEN123",
"purchaseInvoiceLines": [
{
"itemId": "bfc03c90-2fe0-47fc-9f51-a4d2c605944c",
"description": "Some custom material",
"quantity": 5
},
{
"itemId": "bfc03c90-2fe0-47fc-9f51-a4d2c605944c",
"description": "Some more custom material",
"quantity": 10
}
]
}
I don't see how I am able to create the purchaseInvoiceLines json array with the PurchaseInvoice.builder() function generated from the metadata (metadata file attached)
I am able to generate the invoice by doing individual posts for the PurchaseInvoice and PurchaseInvoiceLine but would like to combine it into a single post.
from odata-client.
Sorry @mbasboll I missed this (or read it quickly and forgot to get back to it!), feel free to nag me about stuff. I'll have a look.
from odata-client.
I generated from your metadata and I'd expect the exchange to go like this:
PurchaseInvoice x = nav.companies().purchaseInvoices().post(PurchaseInvoice.builder()....build());
nav.companies().purchaseInvoices(x.getId().get()).purchaseInvoiceLines().post(list);
Of course we aren't able to pass a list.
You know I assume that you can use custom requests to do this with the client as a workaround but I'll add an issue to be able to add a a list of items for the post (and I'll check the OData spec in that regard).
from odata-client.
Thanks for taking a look at this. Having the ability to add a list of items in a post would be great. In the meantime, I will take a look at using custom requests.
from odata-client.
@mbasboll I assume that the purchaseInvoice, purchaseInvoiceLine entityTypes in the metadata were created by you? If so then what you can do to allow addition of purchaseInvoiceLines to the purchaseInvoice builder is declare a purchaseInvoiceLine as a ComplexType not an EntityType. That way it will effectively be an embedded collection inside a PurchaseInvoice. Of course if you want to edit one PurchaseInvoiceLine then you need to replace the collection in the PurchaseInvoice but that might be ok?
from odata-client.
I have not created any of the entityTypes. All of the entityTypes in the metadata are straight from Microsoft. The metadata file is directly from v2.0 of the Business Central API:
https://api.businesscentral.dynamics.com/v2.0/environmentid/sandbox/api/v2.0/$metadata
I have successfully tested creating a purchase invoice using postman. Below is a sample url and json body. As you can see this has two collection levels (purchaseInvoiceLines and dimensionSetLines)
Would Microsoft be doing something outside of the odata standard to accomplish this?
Sample post url:
https://api.businesscentral.dynamics.com/v2.0/environmentid/sandbox/api/v2.0/companies(companyid)/purchaseInvoices
json body:
{
"number": "127",
"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"
}
]
}
]
}
from odata-client.
Related Issues (20)
- How to get partial range of content of a drive item(file) HOT 9
- DriveItem does not have the @microsoft.graph.downloadUrl property HOT 6
- Issue with Microsoft Dynamics EntityDefinitions/RelationshipDefinitions HOT 2
- Onedrive delta link, does not give top(2), but gives all changes though top is added HOT 3
- [Documentation] Authentication with OData Service HOT 7
- Cannot deserialize UnsignedByte using Serializer.deserialize HOT 5
- upload file to onedrive through createUploadSession - itemWithPath() not found HOT 4
- httpResponse of odata.client.HttpResponse put(String s, .List<RequestHeader> list, InputStream inputStream, int i,HttpRequestOptions httpRequestOptions) does not give reponse body in httpResponse.getText() as post() method gives. HOT 8
- odata\client\TestingService.class- not returning response body for patchOrPut() method. HOT 17
- post() now does a HTTP PUT HOT 4
- HttpPatch Delta<T> parameter is always Null HOT 1
- odata-client-runtime dependency on jaxb-core and jaxb-impl HOT 2
- Unable to generate a client with dynamics finance and operations metadata HOT 10
- Support "Evolvable Enumerations" with a default value HOT 5
- Hit java reserved identifier 'package' HOT 5
- Automatic mapping of "expanded" objects support? HOT 4
- Requesting an individual resource - request produced using path parameter instead of ID in brackets encoded in URL HOT 2
- How to use @odata.nextLink in graph client sdk to get the next set of messages. HOT 2
- Generated ActionRequest fails with NullPointerException if we provide null for non-required parameters. HOT 4
- odata-client-msgraph: Support for legacy extended properties HOT 33
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from odata-client.