microsoftgraph / msgraph-sdk-java

Microsoft Graph SDK for Java
https://docs.microsoft.com/en-us/graph/sdks/sdks-overview
MIT License
387 stars 133 forks source link

DriveItemCollectionRequestBuilder: functionOptions not added to request #911

Closed npetzall closed 3 years ago

npetzall commented 3 years ago

I believe https://github.com/microsoftgraph/msgraph-sdk-java/blob/4139f70beba18877fbb2dc307700df006d303edb/src/main/java/com/microsoft/graph/requests/DriveItemDeltaCollectionRequestBuilder.java#L63-L65

is missing a call to add functionOptions to requestUrl.

Like in https://github.com/microsoftgraph/msgraph-sdk-java/blob/4139f70beba18877fbb2dc307700df006d303edb/src/main/java/com/microsoft/graph/requests/DriveItemSearchCollectionRequestBuilder.java#L63-L68

npetzall commented 3 years ago

Workaround adding the functionOptions manually

String token = "asdfdsgfsdfgsdfg";
DriveItemDeltaParameterSet driveItemDeltaParameterSet = DriveItemDeltaParameterSet
  .newBuilder()
  .withToken(token)
  .build();
DriveItemDeltaCollectionRequest driveItemDeltaCollectionRequest = driverClient
  .root()
  .delta(driveItemDeltaParameterSet)
  .buildRequest();
driveItemDeltaParameterSet
  .getFunctionOptions()
  .forEach(driveItemDeltaCollectionRequest::addFunctionOption);
DriveItemDeltaCollectionPage driveItemDeltaCollectionPagedriveItemDeltaCollectionRequest.top(1000).get();

But it's a bit weird. Calling delta() without token returns the token in deltaLink as a queryOption. Calling delta() with a functionOption as above will return token as a functionOption,

Adding a QueryOption keeps the returned deltaLink as QueryOption.

ramsessanchez commented 3 years ago

Hi @npetzall, thank you for brining this to our attention. I believe you are right, the call to add the functionOptions does seem missing. Unfortunately, this is an auto-generated library thus I'm not quite sure I am able to add this functionality directly. I'll follow up with those in chare of generation and will get back to you with what the plan is to take care of this issue. Thanks for your patience.

npetzall commented 3 years ago

Since the return without a token is a queryOption, it feels strange that SDK creates a functionOption, just an observation.

MIchaelMainer commented 3 years ago

This issue occurs here: https://github.com/microsoftgraph/MSGraph-SDK-Code-Generator/blob/dev/Templates/templates/Java/requests/BaseMethodCollectionRequestBuilder.java.tt#L76

We are only adding the options when there are parameters.

ramsessanchez commented 3 years ago

Hi @npetzall, once again thank you for your patience. The issue has been located and a fix is currently under review.
Feel free to take a look at the proposed changes to the code generator as well as the resulting changes to the v1 library: https://github.com/microsoftgraph/MSGraph-SDK-Code-Generator/pull/605 https://github.com/microsoftgraph/msgraph-sdk-java/pull/916