curl 无法提取报告数据:获取“无法反序列化ReportingRequest”错误

vh0rcniy  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(97)

我正在尝试使用python从Spotify Ads API获取报告数据:

reports = requests.post('https://api-partner.spotify.com/ads/v1.3/adAccounts/8a578aa1-e36d-42da-8110-52914f99f907/report',headers=headers,data=data)

我不断收到此错误:

{"error":{"type":"ParsingError","message":"Request is invalid","errors":["Could not deserialize ReportingRequest"],"sp_trace_id":"89e3b470-6bdd-4e03-8903-d4e814e71164"}}

标头部分是正确的,因为它与其他API端点(如“获取活动数据”)一起工作,但我怀疑错误是因为“数据”部分,该部分由以下内容给出:

data = {
    "filters": {
    "campaign_ids": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "ad_set_ids": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "ad_ids": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "advertiser_ids": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "country_isos": [
      "string"
    ],
    "region_ids": [
      0
    ],
    "dma_ids": [
      0
    ],
    "platforms": "IOS",
    "campaign_statuses": "ACTIVE",
    "ad_set_statuses": "ACTIVE",
    "ad_set_start_dates": [
      "2019-08-24T14:15:22Z"
    ],
    "ad_set_end_dates": [
      "2019-08-24T14:15:22Z"
    ],
    "cost_type_filters": "CPCL",
    "report_datetime_range": {
      "report_start": "2019-08-24T14:15:22Z",
      "report_end": "2019-08-24T14:15:22Z"
    }
  },
  "dimensions": "CAMPAIGN",
  "fields": "CLICKS",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "ad_account_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "continuation_token": "string",
  "page_size": 0
}

我尝试使用curl命令而不是python,但在终端中仍然出现相同的错误:

curl --request POST \
  --url https://api-partner.spotify.com/ads/v1.3/report \
  --header 'Authorization: ' \
  --header 'Content-Type: application/json' \
  --data '{
  "filters": {
    "campaign_ids": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "ad_set_ids": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "ad_ids": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "advertiser_ids": [
      "497f6eca-6276-4993-bfeb-53cbbbba6f08"
    ],
    "country_isos": [
      "string"
    ],
    "region_ids": [
      0
    ],
    "dma_ids": [
      0
    ],
    "platforms": "IOS",
    "campaign_statuses": "ACTIVE",
    "ad_set_statuses": "ACTIVE",
    "ad_set_start_dates": [
      "2019-08-24T14:15:22Z"
    ],
    "ad_set_end_dates": [
      "2019-08-24T14:15:22Z"
    ],
    "cost_type_filters": "CPCL",
    "report_datetime_range": {
      "report_start": "2019-08-24T14:15:22Z",
      "report_end": "2019-08-24T14:15:22Z"
    }
  },
  "dimensions": "CAMPAIGN",
  "fields": "CLICKS",
  "organization_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "ad_account_ids": [
    "497f6eca-6276-4993-bfeb-53cbbbba6f08"
  ],
  "continuation_token": "string",
  "page_size": 0
}'
q3qa4bjr

q3qa4bjr1#

当我以下面的形式传递数据时,我能够得到响应:

data = {
   "dimensions": [
"COST_TYPE"
],
"fields": [
"CLICKS",
"COMPLETES",
"COMPLETION_RATE",
"CONVERSION_RATE",
"CTR",
"ECPCL",
"ECPM",
"ERRORS",
"FETCHES",
"FETCH_REACH",
"FIRST_QUARTILES",
"IMPRESSIONS",
"INTENT_RATE",
"LISTENERS",
"MIDPOINTS",
"NEW_LISTENERS",
"NEW_LISTENER_CONVERSION_RATE",
"NEW_LISTENER_STREAMS",
"OFF_SPOTIFY_IMPRESSIONS",
"PAID_LISTENS",
"PAID_LISTEN_FREQ",
"PAID_LISTEN_REACH",
"RENDER_RATIO",
"SERVES",
"SERVE_FREQ",
"SERVE_REACH",
"SKIPS",
"SPEND",
"STARTS",
"STREAMS",
"STREAMS_PER_NEW_LISTENER",
"STREAMS_PER_USER",
"THIRD_QUARTILES"
],
"filters": {

"ad_ids": [
      "5e30eed4-a4fe-4f8e-854c-33b438ab11b6"
    ],
"report_datetime_range": {
      "report_start": "2022-07-13T00:00:00Z",
      "report_end": "2022-07-16T23:00:00Z"
    }

},
}

问题似乎出在report_start和report_end日期上。根据文档,分钟和秒必须按00:00传递,如上所示

相关问题