Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

analytics-1.4-apis data-sources-api

sgiostra
Level 1
Level 1

Hi,
we're using the data-sources-api of analytics-1.4-apis and we got this error: "invalid columns, at least one is required and columns must match for each upload" when we try to use DataSources.UploadData.

We using python 3.7 with the requests library.

As required by the APi ( sees the doc ), on the post request  we define the columns parameter as array of string:

columns = ["Date", "Evar 96", "Event 97", "Event 99", "Event 98", "Event 100"]
rows = [
["12/31/2020", "100011173", "1", "2", "3", "4"],
["01/29/2021", "100011173", "1", "3", "4", "5"],
["01/30/2021", "100011173", "2", "6", "5", "6"],
["01/31/2021", "100011173", "3", "4", "5", "6"],
["02/01/2021", "100011173", "4", "5", "6", "7"],
]

 

and give it to the API as item of the payload:

payload = {
"columns": columns,
"dataSourceID": dataSourceID,
"finished": True,
"jobName": "pippo123",
"reportSuiteID": rsid,
"rows": rows
}


url = "https://api.omniture.com/admin/1.4/rest/?method="
response = requests.post(url + "DataSources.UploadData", headers=header, data=payload)

 

Now we don't undertand because we got the error?

 

Thanks, Stefano G.

1 Accepted Solution
Khurshid_Alam
Correct answer by
Employee
Employee

Can you check if "rows" matches with columns? If you can share rows with some the values here, I can review that.

View solution in original post

5 Replies
Khurshid_Alam
Correct answer by
Employee
Employee

Can you check if "rows" matches with columns? If you can share rows with some the values here, I can review that.

View solution in original post

sgiostra
Level 1
Level 1

Hi Khurshid,

I've updated the question with the rows that i'm using in the test

rows = [
["12/31/2020", "100011173", "1", "2", "3", "4"],
["01/29/2021", "100011173", "1", "3", "4", "5"],
["01/30/2021", "100011173", "2", "6", "5", "6"],
["01/31/2021", "100011173", "3", "4", "5", "6"],
["02/01/2021", "100011173", "4", "5", "6", "7"],
]
Khurshid_Alam
Employee
Employee
I see the payload is fine, except that the last row in "rows" has comma.
sgiostra
Level 1
Level 1

Hi Khurshid,

i found the issue, the cause is not the comma (Python allow trailing comma in a dictonary and clean it before to convert the dict in a "real" JSON).

To resolve the issue, in the requests.post call I must pass the parameters as json and not as data:

 

response = requests.post(url + "DataSources.UploadData", headers=header, json=payload)

 

 

Khurshid_Alam
Employee
Employee
I have limited experience in Python so could not catch the issue. Glad you identified it.