Expand my Community achievements bar.

SOLVED

Problem with same ItemIDs passed in Python code

Avatar

Level 1

Hello

 

I am writing a Python code to extract data from Adobe Analytics via the standard API calls. My requirement is to extract data like impressions, clicks, page views etc., broken by few dimensions. 

 

When I pass the metrics in the metricContainer however I am getting this error: 

 

{"errorCode":"invalid_data","errorDescription":"Request contained multiple filters with id=0","errorId":"a072dedc-120c-45b7-8d94-5e4f9c20900a"}

 

I know the error but I don't know how to handle this. If I cannot have multiple filters with same ID value of "zero" how can I handle such situations?

 

Please help

 

1 Accepted Solution

Avatar

Correct answer by
Level 1

Hello. I tried in Swagger UI earlier but I thought this complete code may not be suitable to run in the entire Swagger UI. Please find below the request body. 

 

body1_ind4 = {
'rsid': client,
'globalFilters': [{'type': 'dateRange', 'dateRange': date_str}],
'metricContainer': {
'metrics': [{"id": "metrics/visits", "filters": [il1, il2, il3]},
{"id": "metrics/pageviews", "filters": [il1, il2, il3]},
{"id": "metrics/revenue", "filters": [il1, il2, il3]},
{"id": "metrics/event42", "filters": [il1, il2, il3]},
{"id": "metrics/itemtimespent", "filters": [il1, il2, il3]},
{"id": "metrics/units", "filters": [il1, il2, il3]},
{"id": "metrics/orders", "filters": [il1, il2, il3]},
{"id": "metrics/event6", "filters": [il1, il2, il3]},
{"id": "metrics/visitors", "filters": [il1, il2, il3]}],
"metricFilters": [
{"id": il2, "type": "breakdown", "dimension": "variables/searchenginenatural","itemId": il2},
{"id": il3, "type": "breakdown", "dimension": "variables/campaign","itemId": il3},
{"id": il1, "type": "breakdown", "dimension": "variables/daterangeday","itemId": il1}
]},
'dimension': 'variables/referringdomain',
"settings": {"dimensionSort": "asc","countRepeatInstances": False}
}

I believe if the values of il2 and il3 are same and equal to zero the error throws out. I am not sure why two itemIds can have the same values in Adobe Analytics.

 

Regards

 

Krishna

View solution in original post

4 Replies

Avatar

Level 7

@kkrishna_hyd  Before executing the API in Python I will suggest you try it in Swagger API so that you can manipulate the requests easily and get the desired result.

https://adobedocs.github.io/analytics-2.0-apis/

From the error you are getting it seems like you are using multiple filters in metrics container for a particular metric id object. I will suggest to try in the above link and modify the request accordingly. If not solved than provide a sample request body which you sending to the endpoint.

Avatar

Correct answer by
Level 1

Hello. I tried in Swagger UI earlier but I thought this complete code may not be suitable to run in the entire Swagger UI. Please find below the request body. 

 

body1_ind4 = {
'rsid': client,
'globalFilters': [{'type': 'dateRange', 'dateRange': date_str}],
'metricContainer': {
'metrics': [{"id": "metrics/visits", "filters": [il1, il2, il3]},
{"id": "metrics/pageviews", "filters": [il1, il2, il3]},
{"id": "metrics/revenue", "filters": [il1, il2, il3]},
{"id": "metrics/event42", "filters": [il1, il2, il3]},
{"id": "metrics/itemtimespent", "filters": [il1, il2, il3]},
{"id": "metrics/units", "filters": [il1, il2, il3]},
{"id": "metrics/orders", "filters": [il1, il2, il3]},
{"id": "metrics/event6", "filters": [il1, il2, il3]},
{"id": "metrics/visitors", "filters": [il1, il2, il3]}],
"metricFilters": [
{"id": il2, "type": "breakdown", "dimension": "variables/searchenginenatural","itemId": il2},
{"id": il3, "type": "breakdown", "dimension": "variables/campaign","itemId": il3},
{"id": il1, "type": "breakdown", "dimension": "variables/daterangeday","itemId": il1}
]},
'dimension': 'variables/referringdomain',
"settings": {"dimensionSort": "asc","countRepeatInstances": False}
}

I believe if the values of il2 and il3 are same and equal to zero the error throws out. I am not sure why two itemIds can have the same values in Adobe Analytics.

 

Regards

 

Krishna

Avatar

Level 1

Hello. I tried in Swagger UI earlier but I thought this complete code may not be suitable to run in the entire Swagger UI. Please find below the request body. 

 

body1_ind4 = {
'rsid': client,
'globalFilters': [{'type': 'dateRange', 'dateRange': date_str}],
'metricContainer': {
'metrics': [{"id": "metrics/visits", "filters": [il1, il2, il3]},
{"id": "metrics/pageviews", "filters": [il1, il2, il3]},
{"id": "metrics/revenue", "filters": [il1, il2, il3]},
{"id": "metrics/event42", "filters": [il1, il2, il3]},
{"id": "metrics/itemtimespent", "filters": [il1, il2, il3]},
{"id": "metrics/units", "filters": [il1, il2, il3]},
{"id": "metrics/orders", "filters": [il1, il2, il3]},
{"id": "metrics/event6", "filters": [il1, il2, il3]},
{"id": "metrics/visitors", "filters": [il1, il2, il3]}],
"metric Filters": [
{"id": il2, "type": "breakdown", "dimension": "variables/searchenginenatural","itemId": il2},
{"id": il3, "type": "breakdown", "dimension": "variables/campaign","itemId": il3},
{"id": il1, "type": "breakdown", "dimension": "variables/daterangeday","itemId": il1}
]},
'dimension': 'variables/referringdomain',
"settings": {"dimensionSort": "asc","countRepeatInstances": False}
}

I believe if the values of il2 and il3 are same and equal to zero the error throws out. I am not sure why two itemIds can have the same values in Adobe Analytics.

 

Regards

 

Krishna

Avatar

Employee

I would suggest running the desired report in Adobe Analytics Workspace, open Workspace Debugger, copy the curl request and convert it to Python code (using Postman).