试图获取报告,但总是得到“ReportDownloadError.MISSING_PARAMETER”“缺少报告定义”

时间:2016-09-01 09:39:41

标签: curl google-adwords

我在使用adwords API时遇到了问题,并想知道您是否可以帮助我。

我打电话给adwords api http:// adwords.google.com/api/adwords/reportdownload/v201603。

这个api一直工作到昨天,但今天就停止了工作。

我阅读了参考页面并试图弄清楚,但到目前为止我们只得到了'api error'作为回应。

以下是这些网页的链接。

https:// developers.google.com/adwords/api/docs/guides/reporting?hl=en

https:// adwords.google.com/api/adwords/reportdownload/v201603/reportDefinition.xsd

以下是我们写的,

API_VERSION='v201603'
REQUEST='__rdxml=<reportDefinition xmlns="https://adwords.google.com/api/adwords/cm/'${API_VERSION}'">
    <selector>
      <fields>Ctr</fields>
      <fields>Date</fields>
    </selector>
    <reportName>ACCOUNT_PERFORMANCE_REPORT</reportName>
    <reportType>ACCOUNT_PERFORMANCE_REPORT</reportType>
    <dateRangeType>LAST_MONTH</dateRangeType>
    <downloadFormat>XML</downloadFormat>
</reportDefinition>'

SIZE=${#REQUEST}

echo ${REQUEST} | \
curl -X POST \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
    -H 'Authorization: Bearer '${REFREASH_TOKEN} \
    -H 'developerToken: '${DEVELOPER_TOKEN} \
    -H 'clientCustomerId: '${ACCOUNT_ID} \
    -H 'skipReportHeader: False' \
    -H 'skipColumnHeader: False' \
    -H 'skipReportSummary: False' \
    -H 'includeZeroImpressions: False' \
    -H 'Host: adwords.google.com' \
    -H 'Content-Length: '${SIZE} \
    -H 'Expect: 100-continue' \
    -H 'Connection: Keep-Alive' \
  --data-urlencode @- \
  --verbose \
  https://adwords.google.com/api/adwords/reportdownload/${API_VERSION}

在执行代码后,我得到以下的回复

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<reportDownloadError>
  <ApiError>
    <type>ReportDownloadError.MISSING_PARAMETER</type>
    <trigger>Missing report definition</trigger>
    <fieldPath/>
  </ApiError>
</reportDownloadError>

我希望你能给我们关于如何调用报告下载api的说明。

提前致谢,

1 个答案:

答案 0 :(得分:1)

我为python尝试了AdWords API客户端库。 https://github.com/googleads/googleads-python-lib/blob/master/README.md#getting-started

所以,我得到了错误的错误。

Traceback (most recent call last):
  File "examples/adwords/v201607/reporting/download_criteria_report.py", line 61, in <module>
    main(adwords_client)
  File "examples/adwords/v201607/reporting/download_criteria_report.py", line 56, in main
    skip_report_summary=False)
  File "/Users/my/.pyenv/versions/anaconda3-2.3.0/lib/python3.4/site-packages/googleads/adwords.py", line 1169, in DownloadReport
    output, **kwargs)
  File "/Users/my/.pyenv/versions/anaconda3-2.3.0/lib/python3.4/site-packages/googleads/adwords.py", line 1439, in _DownloadReport
    response = self._DownloadReportAsStream(post_body, **kwargs)
  File "/Users/my/.pyenv/versions/anaconda3-2.3.0/lib/python3.4/site-packages/googleads/adwords.py", line 1492, in _DownloadReportAsStream
    raise self._ExtractError(e)
googleads.errors.AdWordsReportBadRequestError: Type: AuthorizationError.USER_PERMISSION_DENIED
Trigger: <null>
Field Path: None

此问题的原因是为已删除的用户创建刷新令牌。

注册表oauth帐户。创建刷新令牌。这个问题解决了。

我感谢你阅读它。 到现在为止,我想你已经习惯了我有趣的英文写作。