Apple Search Ads Error: INVALID_ATTRIBUTE_TYPE

I am using Apple search ads API for accessing data out of Apple Ads. But lately, it is giving me error while making the below API call which gives error message "This is an invalid request. At least one field format is not readable by the system.":


API_URL = "https://api.searchads.apple.com/api/v2/reports/campaigns"
params = {"startTime": startdate.strftime("%Y-%m-%d"),
  "endTime": enddate.strftime("%Y-%m-%d"),
  "selector": {
  "orderBy": [{"field": "impressions", "sortOrder": "DESCENDING"}],
  "fields": ["campaignId", "campaignName", "servingStatus", "appName", "STOREFRONT"],
  "pagination": {"offset": 0, "limit": 100}

  },
  "granularity": "DAILY"
  }
resp = requests.post(API_URL, cert=('ThePEMKey.pem', 'TheKey.key'), json=json.dumps(params)


And after printing the response content I am getting the following details:


b'{"data":null,"pagination":null,"error":{"errors":[{"messageCode":"INVALID_ATTRIBUTE_TYPE","message":"This is an invalid request. At least one field format is not readable by the system.","field":"Line#:1 Column#:1"}]}}'


I have gone through various documents but was unable to resolve the issue. Could anyone please help me with this?

Replies

Did you read this:


https://developer.apple.com/documentation/apple_search_ads/get_campaign_level_reports


I would try to mimic as much as possible:

POST https://api.searchads.apple.com/api/v2/reports/campaigns

{
    "startTime": "2019-02-20",
    "endTime": "2019-02-28",
    "selector": {
        "orderBy": [
            {
                "field": "countryOrRegion",
                "sortOrder": "ASCENDING"
            }
        ],
        "conditions": [
            {
                "field": "countriesOrRegions",
                "operator": "CONTAINS_ANY",
                "values": [
                    "US",
                    "GB"
                ]
            },
            {
                "field": "countryOrRegion",
                "operator": "IN",
                "values": [
                    "US"
                ]
            }
        ],
        "pagination": {
            "offset": 0,
            "limit": 1000
        }
    },
    "groupBy": [
        "countryOrRegion"
    ],
    "timeZone": "UTC",
    "returnRecordsWithNoMetrics": true,
    "returnRowTotals": true,
    "returnGrandTotals": true
}


I see a difference in the way you describe fields