java.lang.NoSuchMethodError: com.google.api.client.http.HttpRequest.setResponseReturnRawInputStream(Z)Lcom/google/api/client/http/HttpRequest;

217 views
Skip to first unread message

Stéphane Mustapha OUKNA

unread,
Jan 5, 2023, 4:03:26 AM1/5/23
to Google Ads API and AdWords API Forum
Hi Google APIs Team,

I have this error :

java.lang.NoSuchMethodError: com.google.api.client.http.HttpRequest.setResponseReturnRawInputStream(Z)Lcom/google/api/client/http/HttpRequest;

For the line :
ValueRange response = service.spreadsheets().values().get(spreadsheetId, range).execute();

        
My Code is :

package technicalFunctions

class ReadSpreadsheet {
    private static final String CREDENTIALS_FILE_PATH = "C:/Users/soukna/nefertiti_auto/client_secret.json";
    private static final String APPLICATION_NAME = "gcp-nerfertiti";
    private static final JsonFactory JSON_FACTORY = GsonFactory.getDefaultInstance();
    private static final String TOKENS_DIRECTORY_PATH = "tokens";

    private static final List<String> SCOPES = Collections.singletonList(SheetsScopes.SPREADSHEETS_READONLY);

    //cette méthode valide d'abord notre demande et crée une connexion entre la bibliothèque d'API Google Sheets.
    private static Credential getCredentials(final NetHttpTransport HTTP_TRANSPORT) throws IOException {
        // Load client secrets.
        InputStream in1 = new FileInputStream(CREDENTIALS_FILE_PATH);
        if (in1 == null) {
            throw new FileNotFoundException("Resource not found: " + CREDENTIALS_FILE_PATH);
        }
        GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in1));

        // Build flow and trigger user authorization request.
        GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY,clientSecrets, SCOPES).setDataStoreFactory(new FileDataStoreFactory(new java.io.File(TOKENS_DIRECTORY_PATH))).setAccessType("offline").build();
        LocalServerReceiver receiver = new LocalServerReceiver.Builder().setPort(8888).build();
        return new AuthorizationCodeInstalledApp(flow, receiver).authorize("user");
    }

    /**
     * Permet de lire La G-Sheet
     */
    @Keyword
    public static List<List<Object>> getSpreadSheetRecords(String range) throws IOException, GeneralSecurityException {
        final NetHttpTransport HTTP_TRANSPORT = new com.google.api.client.http.javanet.NetHttpTransport()
        final String spreadsheetId = "1LXrgBIZx5K0XXWXBGaJGId1i3r8q_P6dGKhVacCVclo";
        System.out.println("iCi");

        Sheets service = new Sheets.Builder(HTTP_TRANSPORT, JSON_FACTORY,getCredentials(HTTP_TRANSPORT)).setApplicationName(APPLICATION_NAME).build();
        ValueRange response = service.spreadsheets().values().get(spreadsheetId, range).execute();
 
     
        System.out.println("LA"+range+"  "+spreadsheetId);
        List<List<Object>> values = response.getValues();
        if (values == null || values.isEmpty()) {
            System.out.println("No data found.");
            return null;
        } else {
            System.out.println("found");
            return values;
        }
    }
}


3 Weeks and no answer about this issue.

Please HELP ME !!!

Google Ads API and AdWords API Forum

unread,
Jan 5, 2023, 5:28:12 AM1/5/23
to Google Ads API and AdWords API Forum
Re-posting the last inquiry [https://groups.google.com/g/adwords-api/c/blDBedj6c4M] from the forum as it wasn't routed to our support queue.

Regards,
Carmela
Google Ads API Team

Stéphane Mustapha OUKNA

unread,
Jan 5, 2023, 6:10:59 AM1/5/23
to Google Ads API and AdWords API Forum
Thanks Carmela, this is my post :

Google Ads API Forum Advisor

unread,
Jan 5, 2023, 8:23:52 AM1/5/23
to adwor...@googlegroups.com

Hi Stephane,


Thanks for reaching out to the Google Ads API team. I hope you are doing well today.
 

Upon checking the partial logs, I can see that you have encountered a NoSuchMethodError error. The java.lang.NoSuchMethodError occurs when an application does not find a called method at runtime. Note that this forum can only support Google Ads API implementation issues, for the Java Client library build issues, I would suggest reaching out to the client library owner via this Googleads Java Github issue tracker as they should be more equipped to provide guidance on this matter.
 

Regards,

Google Logo
Darwin
Google Ads API Team
 



ref:_00D1U1174p._5004Q2hZwQX:ref
Reply all
Reply to author
Forward
0 new messages