POST JSON数据以支持bi api 404 ERROR

时间:2018-02-21 10:14:07

标签: json api post python-requests powerbi

我正在将一个转换为JSON文件的csv推送到我的power bi api。每个单独的列都在power bi上正确显示,但是,当面对向列添加行的代码时,我收到404错误:

Succes:  200
Succes:  200
response status dataset:  201 
dataset responses:  200

response status rows:  404 {"error":{"code":"ItemNotFound","message":"Column '<pi>event_name</pi>' was not found in specified table, dataset 'sobe_wowvirtualserver|*somenumberhere*'"}}

这些是成功上传的列:

columns_body_raw = {"name": "test", "tables":
    [
        {"name": "test", "columns": 
            [
                { "name": "id", "dataType": "Int64"},
                { "name": "status", "dataType": "string"},
                { "name": "location", "dataType": "string"},
                { "name": "reportLocation", "dataType": "Int64"},
                { "name": "preferences", "dataType": "Int64"},
                { "name": "activity_description", "dataType": "string"},
                { "name": "activity_qualification", "dataType": "string"},
                { "name": "activity_businessActivity", "dataType": "string"},
                { "name": "activity_abbreviation", "dataType": "string"},
                { "name": "planned_start_date", "dataType": "string"},
                { "name": "planned_start_time", "dataType": "string"},
                { "name": "planned_end_date", "dataType": "string"},
                { "name": "planned_end_time", "dataType": "string"},
                { "name": "planned_duration", "dataType": "Int64"},
                { "name": "projected_cost", "dataType": "Int64"},
                { "name": "clock_in_date", "dataType": "string"},
                { "name": "clock_in_time", "dataType": "string"},
                { "name": "clock_out_date", "dataType": "string"},
                { "name": "clock_out_time", "dataType": "string"},
                { "name": "clocked_duration", "dataType": "string"},
                { "name": "break_duration", "dataType": "Int64"},
                { "name": "price", "dataType": "Int64"},
                { "name": "order_no", "dataType": "Int64"},
                { "name": "event_id", "dataType": "Int64"},
                { "name": "department", "dataType": "string"},
                { "name": "department_cost_center", "dataType": "Int64"},
                { "name": "worker_first_name", "dataType": "string"},
                { "name": "worker_preposition", "dataType": "string"},
                { "name": "worker_last_name", "dataType": "string"},
                { "name": "worker_full_name", "dataType": "string"},
                { "name": "personnel_number", "dataType": "Int64"},
                { "name": "partner", "dataType": "string"},
                { "name": "employee_type", "dataType": "string"},
                { "name": "employee_default_cost_center", "dataType": "Int64"},
                { "name": "authorized_partner", "dataType": "string"},
                { "name": "incident", "dataType": "Int64"},
                { "name": "tags", "dataType": "Int64"},
                { "name": "sketch_start_date", "dataType": "string"},
                { "name": "sketch_start", "dataType": "string"},
                { "name": "sketch_end_date", "dataType": "string"},
                { "name": "sketch_end", "dataType": "string"},
                { "name": "delta_time", "dataType": "string"},
                { "name": "delta_plan", "dataType": "Int64"},
                { "name": "delta_clock", "dataType": "Int64"},
                { "name": "event_name", "dataType": "string"} #this is one of the columns that gives an error

            ]
        }
dataset_body = json.dumps(columns_body_raw)

这些是我发生错误的一些行:

dataset_body_raw = { "rows": [{
            "sketch_end": "0",
            "order_no": "2017",
            "activity_qualification": "TEST",
            "clock_out_date": "0",
            "activity_businessActivity": "BUSINESS NAME TEST",
            "clock_in_time": "0",
            "partner": "COMPANY",
            "event_name": "EVENT"
            }]}
    dataset_body = json.dumps(dataset_body_raw)

404错误表明没有event_name列,尽管它列在columns_body_raw中,我可以在我的power bi环境中看到它。

这是power bi的屏幕截图: event_name column

1 个答案:

答案 0 :(得分:0)

我使用了错误的响应数据集ID,因此数据集链接到power bi中较旧版本的数据集,该数据集不包含该特定列。总结:上面的代码是使用power bi API在列中发布行的正确方法。