Upgrade from 5.80.0 to 6.13.0
Hi,
I'm upgrading microsoft graph from 5.80.0 to 6.13.0. The pom.xml part change:
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
<version>6.13.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph-core</artifactId>
<version>3.1.14</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.49.1</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.12.2</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core-http-okhttp</artifactId>
<version>1.12.0</version>
</dependency>
And here I have several questions.
- When I create GraphServiceClient, I will meet the following errors: The type com.microsoft.kiota.authentication.AuthenticationProvider cannot be resolved. The type com.microsoft.kiota.RequestAdapter cannot be resolved
My code is:
final ClientSecretCredential clientSecretCredential = new ClientSecretCredentialBuilder()
.clientId(applicationId).clientSecret(clientSecret).tenantId(tenantId).build();
graphClient = new GraphServiceClient(clientSecretCredential, scope);
- When I get site by site url, in v5, I use:
Site site = graphClient.sites().byId(sitePath).buildRequest().get();In v6, I only find http method in the doc. Could I use:Site site = ggraphClient.sites().bySiteId(sitePath).get(); - When I get DriveItem by path, in v5, I use:
DriveItem item = graphClient.sites(site.id).drives(d.id).root().itemWithPath(itemPath).buildRequest().get();In v6. am I correct:DriveItem item = graphClient.drives().byDriveId(d.getId()).root().withUrl(itemPath).get(); - CollectionResponse issue
For example, I use
ListCollectionPage.getNextPage()in v5.
While in v6, I try to use PageIterator:
PageIterator<com.microsoft.graph.models.List, ListCollectionResponse> pageIterator = new PageIterator.Builder<com.microsoft.graph.models.List, ListCollectionResponse>()
.client(graphClient)
.collectionPage(Objects.requireNonNull(firstPage))
.collectionPageFactory(MessageCollectionResponse::createFromDiscriminatorValue)
.processPageItemCallback(list -> {
listFinalSiteLists.add(list);
return true;
}).build();
pageIterator.iterate();
But it shows "The type com.microsoft.kiota.serialization.ParsableFactory cannot be resolved. "
Could you please give me some suggestions?
Best regards, Susan
There was an upgrade guide from 5 to 6 that explains most of the changes you need but can't seem to find it now
There was an upgrade guide from 5 to 6 that explains most of the changes you need but can't seem to find it now
No, I found the upgrade guide: https://github.com/microsoftgraph/msgraph-sdk-java/blob/main/docs/upgrade-to-v6.md. But it can't solve the problems I meet.
Try removing
From your pom as this is included in microsoft-graph 6.13.0.
The cannot be resolved errors you are getting - are these at runtime or compliation errors? Try building the project and doing a maven clean and install to ensure the libraries are picked up.
I've removed the microsoft-graph-core 3.1.14, but it doesn't work. When I execute mvn clean install, I still failed with error like: ERROR] Failed to execute goal [32morg.eclipse.tycho:tycho-compiler-plugin:1.7.0:compile[m [1m(default-compile)[m on project [sharepointservice[m: [1;31mCompilation failure[m: Compilation failure: [ERROR] **************/MicrosoftGraphService.java:[76] [ERROR] graphClient = new GraphServiceClient(clientSecretCredential, scope); [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] The type com.microsoft.kiota.authentication.AuthenticationProvider cannot be resolved. It is indirectly referenced from required .class files [ERROR] **************/MicrosoftGraphService.java:[76] [ERROR] graphClient = new GraphServiceClient(clientSecretCredential, scope); [ERROR] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [ERROR] The type com.microsoft.kiota.RequestAdapter cannot be resolved. It is indirectly referenced from required .class files [ERROR] 2 problems (2 errors) [ERROR] -> [1m[Help 1][m
There was an upgrade guide from 5 to 6 that explains most of the changes you need but can't seem to find it now
What's missing from this upgrade guide is a link to any v6 JavaDocs. The javadoc jar on Maven Central is empty, nothing but a META-INF directory. Ditto for all the other v6 versions I checked. I'm trying to upgrade a v5 app and frustrated by the lack of JavaDocs. In particular, I'm stumbling around trying to find the import and API for classes like PageIterator, RequestConfiguration , etc. If you won't provide JavaDocs, then at least show the imports in your examples.
My apologies for this experience @susanYYT
As I try to reproduce this, you can add microsoft-kiota-abstractions as a direct dependency and let me know if this unblocks you.
Thank you for the feedback @johnthad. Created https://github.com/microsoftgraph/msgraph-sdk-java/issues/2078 to track it.
@susanYYT
To get sites by URL:
Site site = graphClient.sites().bySiteId(sitePath).get(); should work with the sitePath being "{hostname}:/{server-relative-path}"
Similarly for Drives:
use graphClient.drives().byDriveId("driveId").items().byDriveItemId("itemPath").get() with itemPath as root:/{relative path}: (with trailing colon)
Thanks very much. It works by adding microsoft-kiota-abstractions