INVALID_VALUE

832 views
Skip to first unread message

Warren Halderman

unread,
Oct 4, 2022, 8:10:34 AM10/4/22
to Google Ads API and AdWords API Forum
I'm trying to use the Google Ads API in Apps Script but am getting the following error, which doesn't help me diagnose the problem.

Can someone please provide an example JSON request for the generateKeywordIdeas REST endpoint? I've tried nearly 100 different combinations of variable formats, and they all return the same undescriptive error.

{
  "error": {
    "code": 400,
    "message": "Request contains an invalid argument.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.ads.googleads.v11.errors.GoogleAdsFailure",
        "errors": [
          {
            "errorCode": {
              "keywordPlanIdeaError": "INVALID_VALUE"
            },
            "message": "The input has an invalid value."
          }
        ],
        "requestId": "YGYPoatXaAI1JJhkr2pTww"
      }
    ]
  }
}

Google Ads API Forum Advisor

unread,
Oct 4, 2022, 11:45:44 AM10/4/22
to whald...@bruceclay.com, adwor...@googlegroups.com

Hi Warren,

Thanks for reaching out to the Google Ads API Forum.

Kindly note that the INVALID_VALUE error indicates that the field's value is invalid. The REST endpoint for generateKeywordIdeas in order to get a list of keyword ideas. 

POST https://googleads.googleapis.com/v11/customers/{customerId}:generateKeywordIdeas

You may try below cURL:

curl --location --request POST 'https://googleads.googleapis.com/v11/customers/***:generateKeywordIdeas' \

--header 'Authorization: Bearer ****' \

--header 'developer-token: ** \

--header 'User-Agent: curl' \

--header "login-customer-id: ****" \

--header 'Accept: application/json' \

--header 'Content-Type: application/json' \

--data-raw '{ "keywordSeed": { "keywords": [ "coffee" ] } }'

If you encounter any API error, then you may provide complete logs (complete request and response logs with request ID and request header) generated, so that we can check better.  You may send the complete logs via reply privately to author option.

Regards,

Google Logo
Yasar
Google Ads API Team
 


ref:_00D1U1174p._5004Q2ex5Oy:ref

Warren Halderman

unread,
Oct 4, 2022, 9:07:19 PM10/4/22
to Google Ads API and AdWords API Forum
Hi Yasar,

Thank you for the quick response.
The curl sample you sent works fine, but my problem is with making the equivalent request in Google Apps Script.
Making the exact same request (same endpoint, same headers [with my tokens], same body)  using UrlFetchApp.fetch returns an INVALID_VALUE error.

Warren Halderman

unread,
Oct 4, 2022, 9:12:54 PM10/4/22
to Google Ads API and AdWords API Forum
Oh my sweet jesus I was using 'body' instead of 'payload' in UrlFetchApp's .fetch method this whole time.
Gods damn this UrlFetchApp implementation.

Thanks for your help Yasar, all's fixed.

Google Ads API Forum Advisor

unread,
Oct 5, 2022, 2:56:23 AM10/5/22
to whald...@bruceclay.com, adwor...@googlegroups.com
Hi Warren,

Thank you for raising your concern to our team.

It appears that the issue has been resolved on your end. However, since it appears that there is an issue with how you construct the API requests using AppScripts, then this is outside of our scope already so we wouldn't be able to provide support here. With this, I would suggest reaching out to the more equipped team that can provide support to this topic via this link.

Regards,
Google Logo
Ernie John
Google Ads API Team
 


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