getting GoogleAdsException from ApiException (PHP)

357 views
Skip to first unread message

Michael Shepard

unread,
Jan 2, 2024, 2:50:16 PM1/2/24
to Google Ads API and AdWords API Forum
I'm using the php library v15 in a laravel application.I'm trying to catch exceptions and request policy exemptions like it is shown in the keywords example in the github repo. however, I'm throwing an ApiException NOT a GoogleAdsException. I've included an example of what my exception looks like. How do I create a GoogleAdsException from the ApiException so I can work with that instead of the ApiException? Any advice would be helpful.

Thanks!!

Google\ApiCore\ApiException: {
    "message": "Request contains an invalid argument.",
    "code": 3,
    "status": "INVALID_ARGUMENT",
    "details": [
        {
            "@type": "type.googleapis.com\/google.ads.googleads.v15.errors.GoogleAdsFailure",
            "errors": [
                {
                    "errorCode": {
                        "policyViolationError": "POLICY_ERROR"
                    },
                    "message": "A policy was violated. See PolicyViolationDetails for more detail.",
                    "trigger": {
                        "stringValue": "3012944502"
                    },
                    "location": {
                        "fieldPathElements": [
                            {
                                "fieldName": "operations",
                                "index": 2
                            },
                            {
                                "fieldName": "create"
                            },
                            {
                                "fieldName": "keyword"
                            },
                            {
                                "fieldName": "text"
                            }
                        ]
                    },
                    "details": {
                        "policyViolationDetails": {
                            "externalPolicyDescription": "Remove any phone number in the ad text. If you want customers to call you, consider using call extensions or call-only ads.",
                            "key": {
                                "policyName": "PHONE_NUMBER_IN_AD_TEXT",
                                "violatingText": "3012944502"
                            },
                            "externalPolicyName": "Phone number in ad text",
                            "isExemptible": true
                        }
                    }
                },
                {
                    "errorCode": {
                        "criterionError": "KEYWORD_TEXT_TOO_LONG"
                    },
                    "message": "Keyword text should be less than 80 chars.",
                    "trigger": {
                        "stringValue": "MKD090B-047-KP1-KNMKD090B-047-KP1-KNMKD090B-047-KP1-KNMKD090B-047-KP1-KNMKD090B-047-KP1-KN"
                    },
                    "location": {
                        "fieldPathElements": [
                            {
                                "fieldName": "operations",
                                "index": 3
                            },
                            {
                                "fieldName": "create"
                            },
                            {
                                "fieldName": "keyword"
                            },
                            {
                                "fieldName": "text"
                            }
                        ]
                    }
                }
            ],
            "requestId": "uzgE-DmswM1KKYuAIvyP7Q"
        }
    ]
}

Google Ads API Forum Advisor

unread,
Jan 2, 2024, 5:18:22 PM1/2/24
to mshe...@wakeindustrial.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

By reviewing your concern, I understand that you are getting an error message "INVALID_ARGUMENT". You can refer to this documentation for more information on the common errors related to the Google Ads API.

In order to further investigate the error you encountered, provide us complete API logs (request and response with request-id and request header) generated at your end and uncropped UI screenshot of the Google Ads account where you are facing the issue.

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.NetPHPPythonRuby or Perl 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.!5004Q02r4uw7:ref"

Thanks,
 
Google Logo Google Ads API Team


Michael Shepard

unread,
Jan 3, 2024, 11:17:05 AM1/3/24
to Google Ads API and AdWords API Forum
Yeah but contained within the ApiException is a  GoogleAdsFailure. using the php library how do I create an instance of that  GoogleAdsFailure from the apiException?

Google Ads API Forum Advisor

unread,
Jan 3, 2024, 2:19:32 PM1/3/24
to mshe...@wakeindustrial.com, adwor...@googlegroups.com
Hi,

Thank you for getting back to us.

By reviewing your concern, the issue appears to be a PHP client library specific issue. Kindly reach out to the client library owners as they are better equipped to assist you on this.

I would like to emphasize that our team can only provide assistance with the technical issues/concerns related to the Google Ads API. If you have any issues related to Google Ads API, please feel free to get back to us.
Reply all
Reply to author
Forward
0 new messages