What is the maven dependency for Google My Business V4 API in order to read reviews?

118 views Asked by At

Using this documentation accounts.locations.reviews.get I am trying to read the specific review in JAVA 18, The problem is that I do not find the Maven Dependency for this Old API that is not deprecated yet.
Before I used to do

    MyBusiness.Accounts.Locations.Reviews.Get myReview= mybusiness.accounts().locations().reviews().get(reviewName);
        Review response=myReview.execute();

Now even I am not able to initialise the API!

I tried to add to pom.xml:

enter image description here

<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-mybusiness</artifactId>
<version>v4-rev20211101-1.32.1</version>
but it does not accept and there is an error:

Missing artifact com.google.apis:google-api-services-mybusiness:jar:v4-rev20211101-1.32.1

What I can do?

1

There are 1 answers

0
Shila Mosammami On BEST ANSWER

I found another way to get the review setting up a request to the Google My Business API using the OkHttp client, but still I am interested to know what is the Maven dependency. Here is what I did:

String accessToken = "your_access_token";

        // Construct the URL
        String url = "https://mybusiness.googleapis.com/v4/accounts/" + ACCOUNT_ID + 
                     "/locations/" + LOCATION_ID + "/reviews/" + REVIEW_ID;

            // Create an instance of OkHttpClient
            OkHttpClient client = new OkHttpClient();
    
            // Build the request, adding the required headers
            Request request = new Request.Builder()
                    .url(url)
                    .addHeader("Authorization", "Bearer " + accessToken)
                    .build();
    
            // Execute the request
            try (Response response = client.newCall(request).execute()) {
                // Check if the response was successful
                if (response.isSuccessful() && response.body() != null) {
                    // Extract the response body as a string
                    String responseBody = response.body().string();
                    System.out.println(responseBody);
                } else {
                    // If the response was not successful, handle it appropriately
                    System.out.println("Response not successful: " + response);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }