Upcoming validation of API requests for non-list properties

486 views
Skip to first unread message

Dustin Tseng

unread,
May 20, 2020, 8:48:41 PM5/20/20
to searchads-api-announcements

Starting on June 30, 2020, the Search Ads 360 API will validate API requests to ensure the correct syntax is specified for non-list properties. You won’t be able to make API requests that include list syntax for non-list properties.


Previously JSON array values, as indicated by square brackets [   ], were allowed even though a single value was expected for a property. For example, the “request.reportScope.agencyId” property expects a singular value:


Correct syntax fragment:

"agencyId": "12345678901020304"


Incorrect syntax fragment:

"agencyId": ["12345678901020304"]


Here’s an example of a complete request for Reports: request with correct and incorrect syntax:


Correct request syntax: 

Note that square brackets aren’t included for the agencyId. 

{

  "reportScope":{

    "agencyId":"12345678901020304",

    "advertiserId":"98765432001400280"

  },

  "reportType":"campaign",

  "columns":[

    {

      "columnName":"advertiser"

    },

    {

      "columnName":"campaign"

    }

  ],

  "timeRange":{

    "startDate":"2020-03-09",

    "endDate":"2020-04-09"

  },

  "includeDeletedEntities":true,

  "includeRemovedEntities":true,

  "downloadFormat":"csv",

  "statisticsCurrency":"agency",

  "maxRowsPerFile":10000000

}




Incorrect request syntax:

Note that square brackets are incorrectly included for the agencyId. 


{

  "reportScope":{

    "agencyId":["12345678901020304"],

    "advertiserId":"98765432001400280"

  },

  "reportType":"campaign",

  "columns":[

    {

      "columnName":"advertiser"

    },

    {

      "columnName":"campaign"

    }

  ],

  "timeRange":{

    "startDate":"2020-03-09",

    "endDate":"2020-04-09"

  },

  "includeDeletedEntities":true,

  "includeRemovedEntities":true,

  "downloadFormat":"csv",

  "statisticsCurrency":"agency",

  "maxRowsPerFile":10000000

}


This request will generate 400 error with payload similar to:


{

  "error": {

    "code": 400,

    "message": "Invalid JSON payload received. Unknown name \"agencyId\" at 'body.report_scope': Proto field is not repeating, cannot start list.",

    "errors": [

      {

        "message": "Invalid JSON payload received. Unknown name \"agencyId\" at 'body.report_scope': Proto field is not repeating, cannot start list.",

        "reason": "invalid"

      }

    ],

    "status": "INVALID_ARGUMENT"

  }

}


Search Ads 360 reference page


The Search Ads 360 API reference enumerates all the valid properties and their value types. When the type indicated is not “list” (for example, “long”, “string”, etc.), only one value will be accepted. The use of JSON arrays is only valid when the property expects values of type “list”.



Reply all
Reply to author
Forward
0 new messages