Upload a file (internal error)

Hello,

I try to upload a file in my model, with API via a windows script like below.

I try to upload like the api use requirements, but I ave an internal error on the second step

 

STEP 1 : upload a file as a single chunk

CURL --user user@xxxx.fr:password --header "Content-Type:application/octet-stream" -X PUT -d {"id":"113000000007","name":"Coefficient EPS.csv","chunkCount":-1,"firstDataRow":2,"headerRow":1} https://api.anaplan.com/1/3/workspaces/xx71/models/xx3D/files/113000000007 --upload-file C:\MPA_DEV\SCRIPT_WINDOWS\CoefficientEPS.csv


STEP 2 : Complete the upload

CURL --user user@xxxx.fr:password --header "Content-Type:application/json" -X POST -d {"id":"113000000007","name":"Coefficient EPS.csv","chunkCount":1,"firstDataRow":2,"headerRow":1} https://api.anaplan.com/1/3/workspaces/xx71/models/xx3D/files/113000000007

On the Step2, I have an error :

{
"status" : {
"code" : 500,
"message" : "Internal Server Error"
},
"path" : "/1/3/workspaces/xx71/models/xx3D/files/113000000007",
"timestamp" : "2020-10-03T17:01:41.773356Z"
}

Can you help me, please ?

Answers

  • You can't both upload file data and set file attributes in your first request. If the file is already set up correctly (firstDataRow/headerRow) then just the PUT without the -d argument but with the -upload-file argument should be sufficient, no need for a completion request. I'm assuming the file is no bigger than a few megabytes.