Developer's reference guide

Format for input data

Attention! This documentation refers to the obsolete version of the API, which is no longer available. Please use the new version of the Yandex.Metrica API.

Input data structures for POST and PUT methods are passed in the request body. Input structures match the output structures of the GET methods of the corresponding resources.

Tip. 

To properly form the input structure for a POST or PUT method, call the GET method for a resource that already exists. Copy the resulting structure and define all the necessary field values.

The API POST and PUT methods accept input data in the following formats:

  • XML (by default).
  • JSON.

The format of input data is specified in the HTTP Content-Type header. Possible header values:

  • application/x-yametrika+xml or text/xml
  • application/x-yametrika+json or application/json

Note. 

Sample requests are provided in the section Results format.

If the Content-Type header is not included in the request, Yandex.Metrica determines the data format automatically. The service returns the HTTP status 400 Bad Request in the following cases:

  • The transmitted data is not valid as either XML or JSON.
  • The data structure contains errors.
  • The Content-Type header specifies XML format, but the data structure that was sent is correctly formed for JSON (or vice versa).

xml json