Q
Q
q2mber22017-03-28 01:54:25
API
q2mber2, 2017-03-28 01:54:25

How to get the Yandex Direct API report?

I take an example from the page https://tech.yandex.ru/direct/doc/reports/example-... I
substitute my sandbox token, campaign ID and sandbox URL

curl \
  -H 'Authorization: Bearer AQAAAAAXZmPmAAQQaVHiaEcDHUBitQkG23T2oSk' \
  -d '<?xml version="1.0" encoding="UTF-8"?>
    <ReportDefinition xmlns="http://api.direct.yandex.com/v5/reports">
      <SelectionCriteria>
        <Filter>
          <Field>CampaignId</Field>
          <Operator>EQUALS</Operator>
          <Values> 193407 </Values>
        </Filter>
      </SelectionCriteria>
      <FieldNames>Date</FieldNames>
      <FieldNames>Clicks</FieldNames>
      <FieldNames>Cost</FieldNames>
      <FieldNames>AdNetworkType</FieldNames>
      <OrderBy>
        <Field>Date</Field>
      </OrderBy>
      <ReportName>Campaign #10002, August</ReportName>
      <ReportType>CUSTOM_REPORT</ReportType>
      <DateRangeType>THIS_MONTH</DateRangeType>
      <Format>TSV</Format>
      <IncludeVAT>NO</IncludeVAT>
      <IncludeDiscount>NO</IncludeDiscount>
    </ReportDefinition>' \
  https://api-sandbox.direct.yandex.com/json/v5/reports

in response I get, despite the fact that the rest of the examples work as they should
{"error":{"error_detail":"Not able to process JSON","request_id":"6455035304750394714","error_string":"Invalid request","error_code":"8000"}}

Tell me please

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Smolinsky, 2017-05-09
@NewLifeMan

and what Content-Type are you passing in the headers?

I
iurewa, 2018-03-29
@iurewa

The method you are trying to call takes json as input, and the request body is in xml.
https://api-sandbox.direct.yandex.com/json/v5/reports - pay attention to /json/
You can use another method to work with xml https://api-sandbox.direct.yandex.com/v5/ reports
Or pass the request body in json format

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question