Help with POST dataset from Python

Hi I’m trying to upload data to a dataset using Python Script. The script return 200 code and when I look at the dataset the row were created but with NULL DATA. Can you please help me to identify why the script is uploading NULL data instead of real data. Here is the script: By the way I try different encoder for the data too

import csv
import openpyxl
import xlrd
import os
import requests
import requests_oauthlib
import time
import mimetypes
import pandas as pd
from requests_toolbelt.multipart.encoder import MultipartEncoder
from oauthlib.oauth2 import BackendApplicationClient


Extracting data from Excel File

filename = r’PATH TO MY XLSX FILE’
sheetname = ‘Sheet1’
column_names = [‘Year’,‘Quarter’,‘Team’,‘FindingArea’,‘FindingCount’]
excel_read = pd.read_excel(filename, sheet_name=sheetname, usecols=column_names)

num_rows = excel_read.shape[0]
num_cols = excel_read.shape[1]

Converting data from Excel to CSV

csvData = []

for row in range(0, num_rows):
for col in range(0, num_cols):

Saving CSV file locally

csvFileName = r’PATH TO csv FILE’
with open(csvFileName, ‘w’, newline = ‘’) as csvFile:
writer = csv.writer(csvFile)

import_url = BASE_URL+’/api/dataset/import/6’
basename = os.path.basename(csvFileName)
mimetype = mimetypes.guess_type(basename)

‘’‘encoder = MultipartEncoder({
‘dataSetId’ : “6”,
‘files’ : (basename, open(csvFileName, ‘rb’), mimetype),
‘overwrite’ : “1”,
‘csvImport_1’ : ‘11’,
‘csvImport_2’ : ‘12’,
‘csvImport_3’ : ‘13’,
‘csvImport_4’ : ‘14’,
‘csvImport_5’ : ‘15’,

formdata = {
‘overwrite’: 1,
‘csvImport_1’: 11,
‘csvImport_2’: 12,
‘csvImport_3’: 13,
‘csvImport_4’: 14,
‘csvImport_5’: 15,

#Getting Connection to API

def GetAccessToken():
access_token_url = BASE_URL+’/api/authorize/access_token’
client_id = ‘CLIENTID’
client_secret = ‘CLIENT SECRET’
client = BackendApplicationClient(client_id=client_id)
oauth = requests_oauthlib.OAuth2Session(client=client)
token = oauth.fetch_token(token_url = access_token_url, client_id=client_id, client_secret=client_secret)
auth = ‘Bearer ’ + token[u’access_token’]
return auth

token = GetAccessToken()

Uploadind Data to Xibo

result =, files={‘files’:open(csvFileName, ‘rb’)}, headers={‘Authorization’: token}, data=formdata)

#result =, headers={‘Authorization’ : token, ‘Content-Type’ : encoder.content_type}, data=encoder)

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.