Hi Google!

I am still getting the 500 Internal Server Error.

We implemented the new API last week and since then this issue has appeared!

Code:
" public static void lsa_data(GoogleAdsClient googleAdsClient, String
client, String filepath) throws Throwable {
   long startTimeMillis = System.currentTimeMillis();
   LocalDate date = LocalDate.now();

   String query = "SELECT local_services_lead.id, customer.id,
customer.descriptive_name,
local_services_lead_conversation.event_date_time, "
           + " local_services_lead.lead_type,
local_services_lead.category_id, local_services_lead.lead_charged, "
           + " local_services_lead.lead_status,
local_services_lead_conversation.phone_call_details.call_duration_millis, "
           + " local_services_lead.contact_details,
local_services_lead_conversation.message_details.text, "
           + " local_services_lead.credit_details.credit_state,
local_services_lead.credit_details.credit_state_last_update_date_time "
           + " FROM local_services_lead_conversation ";

   String path = filepath;
   File file1 = new File(path);
   file1.mkdir();

   File myObj = new File(path + "lsa" + ".csv");
   if (myObj.createNewFile()) {
       System.out.println("File created: " + myObj.getName());
       myObj.setWritable(true);
       myObj.setReadable(true);
   }

   BufferedWriter myWriter = new BufferedWriter(new FileWriter(path + "lsa"
+ ".csv", false));

 
myWriter.write("lead_id;account_id;business_name;lead_creation_timestamp;lead_type;lead_category;charge_status;lead_status;phone_call_details_call_duration_millis;contact_details;credit_state;credit_state_modified\n");

   List<String> GAQL_QUERY_STRINGS = ImmutableList.of(query);
   GoogleAdsServiceClient serviceClient =
googleAdsClient.getLatestVersion().createGoogleAdsServiceClient();

   System.out.println("serviceClient " + serviceClient);
   for (String gaqlQuery : GAQL_QUERY_STRINGS) {
       System.out.println("gaqlQuery " + gaqlQuery);

       SearchGoogleAdsStreamRequest request =
SearchGoogleAdsStreamRequest.newBuilder()
               .setCustomerId(client)
               .setQuery(gaqlQuery)
               .build();

       System.out.println("request " + request);

       // Retry logic variables
       int retryCount = 0;
       int retrySeconds = 10;
       final int NUM_RETRIES = 3;


    // Retry loop
       while (retryCount < NUM_RETRIES) {
           try {
               ServerStream<SearchGoogleAdsStreamResponse> stream =
serviceClient.searchStreamCallable().call(request);
               System.out.println("stream " + stream);

               for (SearchGoogleAdsStreamResponse response : stream) {
                   System.out.println("response  " + response);
                   for (GoogleAdsRow googleAdsRow :
response.getResultsList()) {
                       // Process each GoogleAdsRow
                       // Write your data handling logic here...
                   }
               }
               break; // If the request is successful, exit the retry loop

           } catch (GoogleAdsException gae) {
               boolean retryableError = false;

               for (GoogleAdsError googleAdsError :
gae.getGoogleAdsFailure().getErrorsList()) {
                   // Check for quota or rate limit errors
                   if (googleAdsError.getErrorCode().getQuotaError() ==
QuotaError.RESOURCE_EXHAUSTED
                           || googleAdsError.getErrorCode().getQuotaError()
== QuotaError.RESOURCE_TEMPORARILY_EXHAUSTED) {
                       retryableError = true;
                       System.err.printf("Received rate exceeded error,
retrying after %d seconds.%n", retrySeconds);
                       Thread.sleep(retrySeconds * 1000); // Wait before
retrying
                       retrySeconds *= 2; // Exponential backoff
                       retryCount++;
                       break;
                   }

                   // Check for internal server error (500-level)
                   if (googleAdsError.getErrorCode().hasInternalError()) {
                       retryableError = true;
                       System.err.println("500 Internal Server Error
occurred. Retrying after " + retrySeconds + " seconds...");
                       Thread.sleep(retrySeconds * 1000); // Wait before
retrying
                       retrySeconds *= 2; // Exponential backoff
                       retryCount++;
                       break;
                   }
               }

               if (!retryableError) {
                   System.err.printf("Non-retryable error occurred: %s%n",
gae);
                   throw gae; // If the error is not retryable, rethrow the
exception
               }

           } catch (Exception e) {
               System.err.printf("Unexpected error occurred: %s%n", e);
               throw e;
           }

           if (retryCount == NUM_RETRIES) {
               throw new Exception(String.format("Could not recover after
%d retries.%n", retryCount));
           }
       }

       try {
           myWriter.close();
       } catch (Exception e) {
           System.err.printf("Error closing writer: %s%n", e);
       }

       try {
           serviceClient.shutdown();
           serviceClient.awaitTermination(5, TimeUnit.SECONDS);
           serviceClient.close();
       } catch (InterruptedException e) {
           System.err.printf("Service client shutdown interrupted: %s%n",
e);
       }
   }

   }
"

and Logs are:

"stream com.google.api.gax.rpc.ServerStream@2d10e0b1

Non-retryable error occurred:
com.google.ads.googleads.v17.errors.GoogleAdsException: request_id:
"c_00CutRYqv_murYT7ZlWw"


Exception in thread "main"
com.google.ads.googleads.v17.errors.GoogleAdsException: request_id:
"c_00CutRYqv_murYT7ZlWw"


at
com.google.ads.googleads.v17.errors.GoogleAdsException$Factory.createException(
GoogleAdsException.java:42)

at
com.google.ads.googleads.v17.errors.GoogleAdsException$Factory.createException(
GoogleAdsException.java:34)

at
com.google.ads.googleads.lib.stubs.exceptions.BaseGoogleAdsException$Factory.createGoogleAdsException(
BaseGoogleAdsException.java:105)

at
com.google.ads.googleads.lib.callables.GoogleAdsExceptionTransformation.transform(
GoogleAdsExceptionTransformation.java:39)

at
com.google.ads.googleads.lib.stubs.callables.ExceptionTransformingServerStreamingCallable$ExceptionTransformingStreamObserver.onError(
ExceptionTransformingServerStreamingCallable.java:71)

at com.google.api.gax.tracing.TracedResponseObserver.onError(
TracedResponseObserver.java:104)

at com.google.api.gax.rpc.RetryingServerStreamingCallable$1.onFailure(
RetryingServerStreamingCallable.java:99)

at com.google.api.core.ApiFutures$1.onFailure(ApiFutures.java:84)

at com.google.common.util.concurrent.Futures$CallbackListener.run(
Futures.java:1130)

at com.google.common.util.concurrent.DirectExecutor.execute(
DirectExecutor.java:31)

at com.google.common.util.concurrent.AbstractFuture.executeListener(
AbstractFuture.java:1298)

at com.google.common.util.concurrent.AbstractFuture.complete(
AbstractFuture.java:1059)

at com.google.common.util.concurrent.AbstractFuture.setException(
AbstractFuture.java:809)

at com.google.api.gax.retrying.BasicRetryingFuture.handleAttempt(
BasicRetryingFuture.java:201)

at
com.google.api.gax.retrying.CallbackChainRetryingFuture$AttemptCompletionListener.handle(
CallbackChainRetryingFuture.java:135)

at
com.google.api.gax.retrying.CallbackChainRetryingFuture$AttemptCompletionListener.run(
CallbackChainRetryingFuture.java:117)

at com.google.common.util.concurrent.DirectExecutor.execute(
DirectExecutor.java:31)

at com.google.common.util.concurrent.AbstractFuture.executeListener(
AbstractFuture.java:1298)

at com.google.common.util.concurrent.AbstractFuture.complete(
AbstractFuture.java:1059)

at com.google.common.util.concurrent.AbstractFuture.setException(
AbstractFuture.java:809)

at
com.google.api.core.AbstractApiFuture$InternalSettableFuture.setException(
AbstractApiFuture.java:92)

at com.google.api.core.AbstractApiFuture.setException(
AbstractApiFuture.java:74)

at com.google.api.core.SettableApiFuture.setException(
SettableApiFuture.java:51)

at com.google.api.gax.rpc.ServerStreamingAttemptCallable.onAttemptError(
ServerStreamingAttemptCallable.java:366)

at com.google.api.gax.rpc.ServerStreamingAttemptCallable.access$600(
ServerStreamingAttemptCallable.java:96)

at com.google.api.gax.rpc.ServerStreamingAttemptCallable$2.onErrorImpl(
ServerStreamingAttemptCallable.java:237)

at com.google.api.gax.rpc.StateCheckingResponseObserver.onError(
StateCheckingResponseObserver.java:84)

at com.google.api.gax.grpc.ExceptionResponseObserver.onErrorImpl(
ExceptionResponseObserver.java:84)

at com.google.api.gax.rpc.StateCheckingResponseObserver.onError(
StateCheckingResponseObserver.java:84)

at
com.google.api.gax.grpc.GrpcDirectStreamController$ResponseObserverAdapter.onClose(
GrpcDirectStreamController.java:148)

at io.grpc.PartialForwardingClientCallListener.onClose(
PartialForwardingClientCallListener.java:39)

at io.grpc.ForwardingClientCallListener.onClose(
ForwardingClientCallListener.java:23)

at
io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(
ForwardingClientCallListener.java:40)

at com.google.api.gax.grpc.ChannelPool$ReleasingClientCall$1.onClose(
ChannelPool.java:569)

at io.grpc.PartialForwardingClientCallListener.onClose(
PartialForwardingClientCallListener.java:39)

at io.grpc.ForwardingClientCallListener.onClose(
ForwardingClientCallListener.java:23)

at
io.grpc.ForwardingClientCallListener$SimpleForwardingClientCallListener.onClose(
ForwardingClientCallListener.java:40)

at com.google.ads.googleads.lib.logging.LoggingInterceptor$1$1.onClose(
LoggingInterceptor.java:113)

at io.grpc.internal.DelayedClientCall$DelayedListener$3.run(
DelayedClientCall.java:489)

at io.grpc.internal.DelayedClientCall$DelayedListener.delayOrExecute(
DelayedClientCall.java:453)

at io.grpc.internal.DelayedClientCall$DelayedListener.onClose(
DelayedClientCall.java:486)

at io.grpc.internal.ClientCallImpl.closeObserver(ClientCallImpl.java:564)

at io.grpc.internal.ClientCallImpl.access$100(ClientCallImpl.java:72)

at
io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInternal(
ClientCallImpl.java:729)

at
io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl$1StreamClosed.runInContext(
ClientCallImpl.java:710)

at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)

at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)

at java.util.concurrent.ThreadPoolExecutor.runWorker(
ThreadPoolExecutor.java:1149)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(
ThreadPoolExecutor.java:624)

at java.lang.Thread.run(Thread.java:748)

Suppressed: java.lang.RuntimeException: Asynchronous task failed

at com.google.api.gax.rpc.ServerStreamIterator.hasNext(
ServerStreamIterator.java:105)

at tin_package.Master.lsa_data(Master.java:6178)

at tin_package.Test.main(Test.java:131)

Caused by: io.grpc.StatusRuntimeException: INTERNAL: Internal error
encountered.

at io.grpc.Status.asRuntimeException(Status.java:533)

... 21 more

"

We are waiting for your kind response.
Thank You


On Mon, Sep 30, 2024 at 2:28 PM Google Ads API Forum Advisor <
adsapi@forumsupport.google> wrote:

> Hi,
>
> Please ignore our previous email.
>
> As per provided information, I could see that you are encountering the '
> INTERNAL_ERROR
> <https://developers.google.com/google-ads/api/docs/common-errors#:~:text=layer%20limitations.-,INTERNAL_ERROR,-Summary>'
> while fetching the data from local services lead conversation. Do note that
> the INTERNAL_ERROR
> <https://developers.google.com/google-ads/api/docs/common-errors#:~:text=layer%20limitations.-,INTERNAL_ERROR,-Summary>
>  occurs
> when something unexpected happens while processing the request. The common
> cause could be the API isn't functioning correctly. However, this is
> transient in nature and the API request will work again when retrying it
> after 30 seconds or some time. You may also retry any requests that failed
> with this error, using an  Exponential backoff
> <https://developers.google.com/google-ads/api/docs/best-practices/error-types#:~:text=When%20you%20retry%20requests%2C%20use%20an%20exponential%20backoff%20policy.%20For%20example%2C%20if%20you%20first%20pause%205%20seconds%20before%20the%20first%20retry%2C%20you%20could%20pause%2010%20seconds%20after%20the%20second%20and%2020%20seconds%20after%20the%20third%20retry.%20Exponential%20backoff%20helps%20ensure%20you%20are%20not%20calling%20the%20API%20too%20aggressively.>
>  schedule
> for the retries. Here is a code example
> <https://developers.google.com/google-ads/api/samples/handle-rate-exceeded-error>
>  demonstrating
> how to implement an exponential back off strategy.
>
> If the issue still persists, then provide us with the below information,
> so that we can investigate this issue further.
>
>    - Date of this issue started
>    - How much time did you wait before retry of a request
>    - complete API logs (request
>    
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#request>
>     and response
>    
> <https://developers.google.com/google-ads/api/docs/concepts/field-service#response>
>     with request-id
>    
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request-id>
>     and request header
>    
> <https://developers.google.com/google-ads/api/docs/concepts/call-structure#request_headers>)
>    generated at your end.
>
> If you are using a client library and haven't enabled the logging yet, I
> would request you to enable logging for the specific client library that
> you are using. You can refer to the guides Java
> <https://developers.google.com/google-ads/api/docs/client-libs/java/logging>
> , .Net
> <https://developers.google.com/google-ads/api/docs/client-libs/dotnet/logging>
> , PHP
> <https://developers.google.com/google-ads/api/docs/client-libs/php/logging>
> , Python
> <https://developers.google.com/google-ads/api/docs/client-libs/python/logging>
> , Ruby
> <https://developers.google.com/google-ads/api/docs/client-libs/ruby/logging>
>  or Perl
> <https://developers.google.com/google-ads/api/docs/client-libs/perl/logging> 
> to
> enable logging at your end. For REST interface requests, you can enable
> logging via the curl command by using the -i flag.
>
> This message is in relation to case
> "ref:!00D1U01174p.!5004Q02vGbA0:ref" (ADR-00269952)
>
> Thanks,
>
> [image: Google Logo] Google Ads API Team
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Google Ads API and AdWords API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/CAPDiXFoy_6S5OJ7YzBti6Jrew9kCYznBBgF1RTnMn6dTymdU8g%40mail.gmail.com.
  • In... Husnain Akbar
    • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
      • ... 'Google Ads API Forum Advisor' via Google Ads API and AdWords API Forum
        • ... Husnain Akbar

Reply via email to