davidmoten / odata-client

Java client generator for a service described by OData CSDL 4.0 metadata. Includes Microsoft Graph clients (v1.0 and Beta), Graph Explorer client, Analytics for DevOps, Dynamics CRM clients
Apache License 2.0
34 stars 8 forks source link

Requesting an individual resource - request produced using path parameter instead of ID in brackets encoded in URL #393

Open BrandU opened 11 months ago

BrandU commented 11 months ago

Hey David,

Quick question - is this somehow achievable using the generated client:

So desired HTTP request form:

{serviceUri}/odata/Constructions(1296481)....

OData generated client by your generator produces:

{serviceUri}/odata/Constructions/1296481/....

For the invocation looking like this:

ugkkClient.constructions(id).select("Id").expand(...)...

It seems that OData standard itself implicitly goes with the 1st form: link (see step 2)

Am I doing something wrong here?

Thank you!

BrandU commented 11 months ago

Hey David,

Found a way how to configure the PathStyle.

HttpService httpService = new ApacheHttpClientHttpService(new Path(ugkkAPIUrl, PathStyle.IDENTIFIERS_IN_ROUND_BRACKETS), this::createClient, (url, m) -> m);

B.

davidmoten commented 11 months ago

Yep, that looks like it. This is similar (and shows setting of PathStyle):

https://github.com/davidmoten/odata-client#how-to-create-a-client-for-your-odata-service-non-microsoft-api-with-bearer-tokens