Apple Search Ads API Reporting POST Method Error

apple search ads python
apple search api
apple search ads help
apple search ads keyword planner
apple search ads wiki
apple ads manager account
apple search ads cost
apple search ads agency

I'm trying to get report data through Apple Search Ads API. So I use the method -H ...\ -d "@TestSearchTermReport.json" -X POST "/v1/reports/campaigns/{cId}/searchterms"

I have included all the headers and credentials. The following is the content of my json data file for the POST body: { "startTime": "2016-11-13", "endTime": "2016-11-13", "timezone": "UTC", "granularity": "DAILY", "selector": { "orderBy":[{"field":"spend","sortOrder":"DESCENDING"}], "fields": ["spend", "taps", "conversions", "avgCPA", "avgCPC", "ttr", "conversionRate"], "pagination": { "offset": 0, "limit": 1000 } }, "groupBy": "countryCode", "returnRowTotals": False, "returnRecordsWithNoMetrics": False }

However, I get the following error message:

{"data":null,"pagination":null,"error":{"errors":[{"messageCode":"INVALID_JSON_REQUEST","message":"This is an invalid json. The request can not be parsed","field":"Line#:1 Column#:3"}]}}

I have tried many times through different ways, but still not working. Is there any smart guys can help me?

Thanks in advance!

Get Campaign Level Reports, URL. POST https://api.searchads.apple.com/api/v3/reports/campaigns If unsuccessful, the HTTP status code indicates the error with details in the error message. Content-Type: Payload Example: Get Campaign Level Reports. Request  Get help managing Apple Search Ads with instructions and tips for getting set up, managing your ads, improving results, and troubleshooting issues.

I was able to get it working using the following curl

curl --cert ./<PI2 CERTIFICATE FILE>.p12 --pass <PI2 CERTIFICATE PASSWORD>  -H "Authorization: orgId=xxx"  -H "Content-Type: application/json" -X POST -d ' {"startTime": "2017-04-06", "endTime": "2017-04-06", "granularity": 2, "selector": {"orderBy":[{"field":"localSpend","sortOrder":"DESCENDING"}], "fields": ["localSpend"], "pagination": { "offset": 0, "limit": 1000 } }, "groupBy": ["COUNTRY_CODE"], "returnRowTotals": false, "returnRecordsWithNoMetrics": false }' "https://api.searchads.apple.com/api/v1/reports/campaigns/campaign name/searchterms"

You can obtain the p12 certificate by following the steps mentioned here https://developer.apple.com/library/content/documentation/General/Conceptual/AppStoreSearchAdsAPIReference/API_Overview.html#//apple_ref/doc/uid/TP40017495-CH7-SW8

If you are using requests in python to make the post call you might have to do some extra work as I did not find any parameters that takes in p12 certificate and password as input. Create a crt file and pem using openssl

openssl pkcs12 -in Apple_Certificate.p12 -out file.crt.pem -clcerts -nokeys
openssl pkcs12 -in Apple_Certificate.p12 -out file.key.pem -nocerts -nodes

and use the following code

headers = {
            'Authorization': 'orgId=<ORG_ID>',
            'Content-Type': 'application/json',
          }
data = ' {"startTime": "%s",
          "endTime": "%s", 
          "granularity": 2, ' \
          '"selector": {"orderBy":[{"field":"localSpend","sortOrder":"DESCENDING"}], ' \
          '"fields": ["localSpend"], "pagination": { "offset": 0, "limit": 1000 } }, ' \
          '"groupBy": ["COUNTRY_CODE"], "returnRowTotals": false, "returnRecordsWithNoMetrics": false }' % (date_report, date_report) 
url = 'https://api.searchads.apple.com/api/v1/reports/campaigns/%s/searchterms' % (your_campaign_id)
r = requests.post(url, headers=headers, data=data,
                                      cert=('<path to crt file>',
                                            '<path to key file>'))

Get Search Terms Level Reports, If unsuccessful, the HTTP status code indicates the error with details in the error Payload Example: Get Search Terms Level Reports. Request; Response. POST https://api.searchads.apple.com/api/v3/reports/campaigns/{campaignId}/  The apns-push-type header field has six valid values. The descriptions below describe when and how to use these values. alert. Use the alert push type for notifications that trigger a user interaction—for example, an alert, badge, or sound.

You can use the postman:

Steps: 1. Import Row text from the Postman -

curl -X GET 'https://api.searchads.apple.com/api/v2/campaigns/124324' -H 'Authorization: orgId=234234' -H 'Content-Type: application/json'

  1. Set certificate and key in Postman settings (My configuration for macOS 😊) -

    1. Now you can use the request at postman -

Apple Search Ads, With the Apple Search Ads Campaign Management API, you can build When you are ready, promote your campaigns to multiple countries or regions and generate reports with meaningful metrics. Call endpoints by using CRUD methods. With Apple Search Ads Advanced, you manage your own campaigns. You choose keywords and audiences, and set your own bids and budgets — paying only when a user taps your ad. Detailed reports let you track key metrics, and our APIs help you measure value and manage at scale.

Get Keyword Level Reports, If unsuccessful, the HTTP status code indicates the error and the details are in the error Payload Example: Get Keyword Level Reports. Request; Response. POST https://api.searchads.apple.com/api/v3/reports/campaigns/{campaignId}/  Ad Languages: Lists the available languages that you may use to write your ads and keywords for each country. Currencies: Contains a list of available currencies for Microsoft Advertising advertising accounts. Editorial Reason Codes: Defines the reason codes of why an ad, keyword, or ad extension failed editorial review. Entity Limits

Campaign Management API - Help, Access documentation and details on how to use the Apple Search Ads Campaign Management API to programmatically manage campaigns and pull reports. Get Started With the Bing Ads API. 6/18/2020; 13 minutes to read; In this article. Any Microsoft Advertising user with a developer token can begin using the Bing Ads API. For advertisers placing a large number of ads or developers building advertising tools, the Bing Ads API provides a programmatic interface to Microsoft Advertising.

Using Apple Search Ads API Functionality, The following list describes the function of CRUD methods in the Apple Search Ads API. POST. Used to create new resources, find resources, and pull reports. Error Codes. The Core Reporting API returns a 200 HTTP status code if a request is successful. If there an error occurs during processing of a query, the API returns an error code and description.

Comments
  • Good and precise answer. pay attention that the certificate_key_path is a pem file