Warnings

  • The Google Ads API allows returning non-blocking errors as warnings when uploading offline data for store sales transactions.

  • To enable warnings, set the enable_warnings field in the request object.

  • Warnings are returned in the warnings field of the response as a Status object containing a list of GoogleAdsError details.

  • Code examples in various client libraries demonstrate how to enable and process these warnings.

  • These examples also show the full workflow for uploading store sales transactions, including job creation, adding operations, and running the job.

In the Google Ads API, you can request that non-blocking errors in requests be returned in the response. This feature—called warnings—lets you handle the non-blocking errors separately at the end of a successful request.

Warnings are supported only for the OfflineUserDataJobService.AddOfflineUserDataJobOperations method when uploading offline data for store sales transactions.

Warnings can be used in two scenarios:

  1. When a feature is scheduled to be deprecated, or a new validation rule is to be introduced in the future, a warning of invalid requests may be provided in the response to give developers a heads up that their requests will be impacted soon. These warnings are expected to eventually become errors.

  2. When the server encounters an error which does not necessarily block the current mutate operation from being committed, the non-blocking error may be returned as a warning instead.

Technical details

To utilize this feature for a method, you’ll need to set the enable_warnings field of the corresponding request object. For example, you can specify the enable_warnings field of the AddOfflineUserDataJobOperationsRequest to retrieve warnings from the OfflineUserDataJobService.AddOfflineUserDataJobOperations method. The service will carry out the operations according to other parameters such as validate_only and enable_partial_failure flags. If the API call succeeds, the non-blocking errors that were encountered during the API call will be returned in the warnings field.

Usage

Assume you are uploading offline data for store sales transactions. You can specify item_attribute as an optional field. Providing a malformed value for this property doesn't block the operation from succeeding. In this case, the error details about the malformed field may be retrieved as a warning.

Create the operations and make the API call

Create the mutate operations and make the API call as usual.

Java

// Issues a request to add the operations to the offline user data job.
AddOfflineUserDataJobOperationsResponse response =
    offlineUserDataJobServiceClient.addOfflineUserDataJobOperations(
        AddOfflineUserDataJobOperationsRequest.newBuilder()
            .setResourceName(offlineUserDataJobResourceName)
            .setEnablePartialFailure(true)
            // Enables warnings (optional).
            .setEnableWarnings(true)
            .addAllOperations(userDataJobOperations)
            .build());
      

C#

// Constructs a request with partial failure enabled to add the operations to the
// offline user data job, and enable_warnings set to true to retrieve warnings.
AddOfflineUserDataJobOperationsRequest request =
    new AddOfflineUserDataJobOperationsRequest()
{
    EnablePartialFailure = true,
    ResourceName = offlineUserDataJobResourceName,
    Operations = { userDataJobOperations },
    EnableWarnings = true,
};

AddOfflineUserDataJobOperationsResponse response = offlineUserDataJobServiceClient
    .AddOfflineUserDataJobOperations(request);
      

PHP

// Issues a request to add the operations to the offline user data job.
/** @var AddOfflineUserDataJobOperationsResponse $operationResponse */
$request = AddOfflineUserDataJobOperationsRequest::build(
    $offlineUserDataJobResourceName,
    $userDataJobOperations
);
// (Optional) Enables partial failure and warnings.
$request->setEnablePartialFailure(true)->setEnableWarnings(true);
$response = $offlineUserDataJobServiceClient->addOfflineUserDataJobOperations($request);