tapi-yandex-metrika
tapi-yandex-metrika copied to clipboard
Ошибка при подключении
При получении отчета,
info = client.create().post(params=params)
request_id = info["log_request"]["request_id"]
report = client.download(requestId=request_id).get()
получаю ошибку вида
`During handling of the above exception, another exception occurred:
YandexMetrikaDownloadReportError Traceback (most recent call last) <class 'str'>: (<class 'TypeError'>, TypeError('str returned non-string (type NoneType)'))
During handling of the above exception, another exception occurred:`
Скрин: http://joxi.ru/J2bG3xDTM453XA
Подскажите, что делаю не так?
Ошибку попозже исправлю, а пока можешь сделать так, это должно помочь:
request_id = info.data["log_request"]["request_id"]
ÐдÑавÑÑвÑйÑе. Ð ÑÑо ÑÑо за оÑибка?
ÐаÑÑ Ð´Ð½ÐµÐ¹ назад ÑÑÐ¾Ñ Ð¶Ðµ ÑамÑй запÑÐ¾Ñ ÑабоÑал.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
line 21, in
HTTP ERROR 404 Not Found
URI: | /management/v1/counter/94854540/logrequest/32638116/part/0/download |
---|---|
STATUS: | 404 |
MESSAGE: | Not Found |
SERVLET: | faced |
Powered by Jetty:// 9.4.45.v20220203
ÐдÑавÑÑвÑйÑе. Ð ÑÑо ÑÑо за оÑибка?
ÐаÑÑ Ð´Ð½ÐµÐ¹ назад ÑÑÐ¾Ñ Ð¶Ðµ ÑамÑй запÑÐ¾Ñ ÑабоÑал.
During handling of the above exception, another exception occurred:
Traceback (most recent call last): line 21, in result = api.download(requestId=request_id).get() line 362, in get return self._make_request("GET", *args, **kwargs) line 336, in _make_request self._api.wrapper_call_exception( line 83, in wrapper_call_exception raise exceptions.YandexMetrikaApiError(response) tapi_yandex_metrika.exceptions.YandexMetrikaApiErrorINFO:root:HEADERS = {'Cache-Control': 'must-revalidate,no-cache,no-store', 'Content-Length': '514', 'Content-Type': 'text/html;charset=iso-8859-1', 'Pragma': 'no-cache', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'DENY', 'X-XSS-Protection': '1; mode=block'} INFO:root:URL = https://api-metrika.yandex.net/management/v1/counter/94851830/logrequest/32638116/part/0/download : 404 Not Found
Error 404 Not Found ## HTTP ERROR 404 Not Found URI: /management/v1/counter/94854540/logrequest/32638116/part/0/download STATUS: 404 MESSAGE: Not Found SERVLET: faced [Powered by Jetty:// 9.4.45.v20220203](https://eclipse.org/jetty)
ÐÑÑаеÑеÑÑ ÑкаÑаÑÑ Ð½ÐµÑÑÑеÑÑвÑÑÑий оÑÑеÑ. Ð¯Ð½Ð´ÐµÐºÑ Ð¼ÐµÑÑика ÑегÑлÑÑно ÑдалÑÐµÑ Ð¾ÑÑеÑÑ, Ð¸Ñ Ð½Ñжно пеÑеÑоздаваÑÑ.
Я использую этот код
api = YandexMetrikaLogsapi(access_token=ACCESS_TOKEN, default_url_params={'counterId': COUNTER_ID}, wait_report=True, receive_all_data=True ) params = { "fields": "ym:s:dateTime,ym:s:clientID,ym:s:isNewUser,ym:s:regionCity,ym:s:visitDuration,ym:s:goalsID,ym:s:UTMCampaign,ym:s:UTMContent,ym:s:lastDirectPhraseOrCond,ym:s:deviceCategory,ym:s:operatingSystemRoot", "source": "visits", "date1": "2023-11-06", "date2": "2023-11-06" }
result = api.create().post(params=params) request_id = result().data["log_request"]["request_id"] result = api.download(requestId=request_id).get() data = result().data
Как мне его изменить, чтобы создать отчет заново?
Я думал, что каждый этот запрос - это создание нового отчета, которые через десятки секунд будет скачан.
может, метрика что-то изменила?
Присоединяюсь: 404 ошибка, до этого работало
@pavelmaksimov новый api_root https://api-metrica.yandex.net/ через c
ÐдÑавÑÑвÑйÑе. Ð ÑÑо ÑÑо за оÑибка? ÐаÑÑ Ð´Ð½ÐµÐ¹ назад ÑÑÐ¾Ñ Ð¶Ðµ ÑамÑй запÑÐ¾Ñ ÑабоÑал. During handling of the above exception, another exception occurred: Traceback (most recent call last): line 21, in result = api.download(requestId=request_id).get() line 362, in get return self._make_request("GET", *args, **kwargs) line 336, in _make_request self._api.wrapper_call_exception( line 83, in wrapper_call_exception raise exceptions.YandexMetrikaApiError(response) tapi_yandex_metrika.exceptions.YandexMetrikaApiErrorINFO:root:HEADERS = {'Cache-Control': 'must-revalidate,no-cache,no-store', 'Content-Length': '514', 'Content-Type': 'text/html;charset=iso-8859-1', 'Pragma': 'no-cache', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'DENY', 'X-XSS-Protection': '1; mode=block'} INFO:root:URL = https://api-metrika.yandex.net/management/v1/counter/94851830/logrequest/32638116/part/0/download : 404 Not Found
Error 404 Not Found ## HTTP ERROR 404 Not Found URI: /management/v1/counter/94854540/logrequest/32638116/part/0/download STATUS: 404 MESSAGE: Not Found SERVLET: faced [Powered by Jetty:// 9.4.45.v20220203](https://eclipse.org/jetty)ÐÑÑаеÑеÑÑ ÑкаÑаÑÑ Ð½ÐµÑÑÑеÑÑвÑÑÑий оÑÑеÑ. Ð¯Ð½Ð´ÐµÐºÑ Ð¼ÐµÑÑика ÑегÑлÑÑно ÑдалÑÐµÑ Ð¾ÑÑеÑÑ, Ð¸Ñ Ð½Ñжно пеÑеÑоздаваÑÑ.
Я понÑл. СмоÑÑиÑе на ÑÑÑлкÑ, на коÑоÑÑÑ Ð¸Ð´ÐµÑ Ð·Ð°Ð¿ÑоÑ, она ÑодеÑÐ¶Ð¸Ñ "management". ÐÐ¾Ñ Ð¾Ð¶Ðµ Ð²Ñ Ð¸ÑполÑзовали клаÑÑ YandexMetrikaManagement. ÐÐ»Ñ Ð»Ð¾Ð³Ñапи надо иÑполÑзоваÑÑ YandexMetrikaLogsapi