Import using Python api insert not happening only update

rahulnair
Occasional Contributor

Import using Python api insert not happening only update

Hello Team,

I am trying to import csv data into Anaplan using API 2. but whenever I import new data is not being inserted 

old values are being updated correctly. 

When I import new data using browser it works perfect.

 

dataFile = open(data.csv, 'r').read().encode('utf-8')
fileUpload = requests.put(uploadURL = ("https://api.anaplan.com/2/0/workspaces/" + {WorkspaceID} + "/models/" + {ModelID}+ "/" + f'files/{fileData["id"]}'), headers=getputHeaders(), data=(dataFile),proxies= configs.proxies)

postImport = requests.post(

"https://api.anaplan.com/2/0/workspaces/" + {WorkspaceID} + "/models/" + {ModelID}+ "/" + f'imports/' + d['anaplanparameters']['importid'] + '/tasks' , headers=postHeaders, data=json.dumps({'localeName': 'en_US'}),proxies= configs.proxies)

 

Above code update old data properly but doesn't insert new data in Anaplan