Search code examples
javamicrosoft-graph-apimicrosoft-graph-sdksmicrosoft-graph-teamsmicrosoft-graph-calendar

Microsoft graph places api is not shown as method in graph client


I am new to microsoft graph api and trying to use "List Places" api using graphClient. Unable to find any places method for graphClient as shown in microsoft document below:

https://learn.microsoft.com/en-us/graph/api/place-list?view=graph-rest-1.0&tabs=java

IGraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();

IRoomCollectionPage microsoft.graph.room = graphClient.places().microsoft.graph.room()
    .buildRequest()
    .get();

Here is my code(cannot see places() method for graphClient object created):

AuthProvider authProvider = new AuthProvider(getTokenUsingGraphClientSecret());
            graphClient = GraphServiceClient.builder().authenticationProvider(authProvider)
                    .buildClient();

token code:

IClientCredential credential = ClientCredentialFactory.createFromSecret(CLIENT_SECRET);
             ConfidentialClientApplication cca =
                     ConfidentialClientApplication
                             .builder(CLIENT_ID, credential)
                             .authority(AUTHORITY)
                             //.setTokenCacheAccessAspect(tokenCacheAspect)
                             .build();

IAuthenticationResult result = cca.acquireToken(parameters).join();

Also, not getting option to import IRoomCollectionPage class.

Note: I am using below dependency in my build.gradle:

    compile group: 'com.microsoft.graph', name: 'microsoft-graph', version: '1.7.1'
    // https://mvnrepository.com/artifact/com.microsoft.azure/msal4j
    compile group: 'com.microsoft.azure', name: 'msal4j', version: '1.5.0'

Please let me know if i am missing something here. Thanks in advance.


Solution

  • Working and testes solutions

       String url = graphClient.places()
                .getRequestUrlWithAdditionalSegment("microsoft.graph.room");
    
       PlaceCollectionPage page = new PlaceCollectionRequestBuilder(url, graphClient, null)
                .buildRequest()
                .get();