I see that I have the correct GET request in Python.
headers = {
'Authorization': f'Bearer {access_token}',
'X-AP-Context': f'orgId={orgId}',
}
r = requests.get('https://api.searchads.apple.com/api/v4/campaigns', headers=headers)
curl_data = r.json()
r
The response of the above is a 200, all good.
I've confirmed using acls, GET request to https://api.searchads.apple.com/api/v4/acls, that I have 'API Read Only' roleName.
When I attempt to use the sample code, with a small modification for 'true' to 'True', as Python requires it capitalized. Sample code is from Apple, as Payload Example 2, on this docs page.
Here is the code explicitly, using same headers as above:
# Payload Example 2: Get Campaign-Level Reports
data = \
{
"startTime": "2021-11-08",
"endTime": "2021-11-09",
"selector": {
"orderBy": [{
"field": "billingEvent",
"sortOrder": "DESCENDING"
}],
"conditions": [{
"field": "billingEvent",
"operator": "IN",
"values": [
"IMPRESSIONS",
"TAPS"
]
}],
"pagination": {
"offset": 0,
"limit": 34
}
},
"timeZone": "UTC",
"returnRecordsWithNoMetrics": False,
"returnRowTotals": True,
"returnGrandTotals": True
}
# making call
url = 'https://api.searchads.apple.com/api/v4/campaigns'
r = requests.post(url=url, data=data, headers=headers)
r
Here I get a 415 response. What is my error? Thanks in advance for any help.
Yours,
Michael