Skip to content

create responsive search ads error #439

@LandonYin

Description

@LandonYin

Which version of the client library are you using?
Latest master to date v5.0.0

Which version of PHP are you using?
7.3.4

Which operating system (Linux, Windows, ...) and version?
Windows10

Actions taken
I am creating a responsive search ad.I set the ad_group filed with reference to this example, but it still prompts me that ad_group is required, it looks like the setting does not take effect.
The following is my running code and log information, please help me find the problem. Thanks.

public function addGroupAd($customer_id,$group_id)
    {
        try{
            $adGroupResourceName = ResourceNames::forAdGroup($customer_id,$group_id);

            // Creates the responsive search ad info.
            $responsiveSearchAdInfo = new ResponsiveSearchAdInfo();
            $responsiveSearchAdInfo->setHeadlines([new AdTextAsset(['text'=> 'head1']),new AdTextAsset(['text'=> 'head2']),new AdTextAsset(['text'=> 'head3'])]);
            $responsiveSearchAdInfo->setDescriptions([new AdTextAsset(['text'=> 'desc1']),new AdTextAsset(['text'=> 'desc2'])]);
            $responsiveSearchAdInfo->setPath1('path1');
            $responsiveSearchAdInfo->setPath2('path2');

            // Builds the final ad group ad representation.
            $adGroupAd = new AdGroupAd([
                'ad_group' => $adGroupResourceName,
                'status'   => AdGroupAdStatus::PAUSED,
                'ad' => new Ad([
                    'final_urls' => ['http://www.example.com'],
                    'responsive_search_ad' => $responsiveSearchAdInfo
                ])
            ]);

            // Creates the operation
            $adGroupAdOperation = new AdGroupAdOperation();
            $adGroupAdOperation->setCreate($adGroupAd);

            // Creates the AdGroupAdServiceClient.
            $adGroupAdServiceClient = parent::client()->getAdGroupAdServiceClient();
            // Adds the AdGroup.
            $adGroupAdResponse = $adGroupAdServiceClient->mutateAdGroupAds($customer_id,[$adGroupAdOperation]);

            $createdAdGroupAdResourceName = $adGroupAdResponse->getResults()[0]->getResourceName();

            dd($createdAdGroupAdResourceName);

        }catch (ApiException $e){
            dd($e->getMessage());
        }
    }

Expected result
The ad was created successfully and get the ResourceName.

Actual result

{
    "message": "Request contains an invalid argument.",
    "code": 3,
    "status": "INVALID_ARGUMENT",
    "details": [
        {
            "@type": "google.ads.googleads.v5.errors.googleadsfailure-bin",
            "data": "<Unknown Binary Data>"
        },
        {
            "@type": "grpc-status-details-bin",
            "data": "<Unknown Binary Data>"
        },
        {
            "@type": "request-id",
            "data": "njrS61O59jkINDvZGgJOmg"
        }
    ]
}

Debug log
Please note that I have deleted the privacy information in the log. If you need the necessary ID and other information, please provide your email.

[2020-10-14T10:16:34.760635+08:00] google-ads.INFO: Request made: Host: "googleads.googleapis.com", Method: "/google.ads.googleads.v5.services.GoogleAdsService/SearchStream", CustomerId: "CustomerId", RequestId: "CustomerId", IsFault: 0, FaultMessage: "None"
[2020-10-14T10:16:36.165938+08:00] google-ads.WARNING: Request made: Host: "googleads.googleapis.com", Method: "/google.ads.googleads.v5.services.AdGroupAdService/MutateAdGroupAds", CustomerId: "CustomerId", RequestId: "RequestId", IsFault: 1, FaultMessage: "["Field 'ad_group' is required for 'CREATE' operation."]"
[2020-10-14T10:16:36.167285+08:00] google-ads.NOTICE: Request
-------
Method Name: /google.ads.googleads.v5.services.AdGroupAdService/MutateAdGroupAds
Host: googleads.googleapis.com
Headers: {
    "x-goog-api-client": "gl-php\/7.3.4 gapic\/ gax\/1.4.0 grpc\/1.28.0",
    "x-goog-request-params": "customer_id=customer_id",
    "developer-token": "REDACTED",
    "login-customer-id": "loginCustomerId"
}
Request: {"customerId":"customerId","operations":[{"create":{"status":"PAUSED","ad":{"finalUrls":["http:\/\/www.example.com"],"responsiveSearchAd":{"headlines":[{},{},{}],"descriptions":[{},{}]}}}}]}

Response
-------
Headers: {
    "request-id": "requestId",
    "date": "Wed, 14 Oct 2020 02:16:37 GMT",
    "alt-svc": "h3-Q050=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-27=\":443\"; ma=2592000,h3-T051=\":443\"; ma=2592000,h3-T050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\""
}

Fault
-------
Status code: 3
Details: Request contains an invalid argument.
Failure: {"errors":[{"errorCode":{"requestError":"REQUIRED_FIELD_MISSING"},"message":"Field 'ad_group' is required for 'CREATE' operation.","location":{"fieldPathElements":[{"fieldName":"operations","index":"0"},{"fieldName":"create"},{"fieldName":"ad_group"}]}}]}  

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions