Highlighted
Occasional Contributor

Anaplan restful api uploads with zip files

Hello,

I have a question about using the Anaplan integration API V2 guide.  Is it possible to upload a csv document inside a .zip file to Anaplan?  I'm able to manually upload a zip file with a csv in it, which works, but cannot figure out if its possible to do it with the API.   I'm trying to do this with Postman but the data being received in Anaplan is all binary.  I'm basically trying to accelerate my uploads via the api using large zipped files.  Do I need to post with a certain header? I'm not sure if this is possible or not?

 

My only headers are:

'Authorization: AnaplanAuthToken bla'

'Content-Type: application/octet-stream'

 

 

 

Thanks,

Tom

9 REPLIES 9
Highlighted
Community Boss

Re: Anaplan restful api uploads with zip files

@tomz 

 

It is not possible with Anaplan Connect. Below is the excerpts from Anaplan Integration guide. But I am not aware how REST API behaves. I believe it should fall on the same lines

 

Misbah_0-1580408674020.png

 

Thanks,

Misbah

Master Anaplanner/Community Boss

Re: Anaplan restful api uploads with zip files

@tomz 

 

First of all Excellent question ! 

 

You need 

 

  1. compress using gzip format
  2. change your header to Content-Type:application/x-gzip

 

Hope this helps

 

 

Highlighted
Occasional Contributor

Re: Anaplan restful api uploads with zip files

I compressed the file to g-zip and tried to send with the header you provided and I get the message: "The server refused this request because the request entity is in a format not supported by the requested resource for the requested method."
Highlighted
Master Anaplanner/Community Boss

Re: Anaplan restful api uploads with zip files

I hope your request method is POST 

 

Perhaps share your postman screenshots so that i can debug 

Highlighted
Occasional Contributor

Re: Anaplan restful api uploads with zip files

 Was using a PUT, which was working with a plain CSV.  Just tested with POST, same bad response.  Maybe its the way i'm uploading the file?

 

Headers:

tomz_0-1580429253254.png

 

Body:

tomz_1-1580429303215.png

 

 

Response:

tomz_2-1580429335754.png

 

Thanks

Highlighted
Master Anaplanner/Community Boss

Re: Anaplan restful api uploads with zip files

your URL looks like you are uploading file as single chunk ? I cannot see the entire URL but i can make out with 80% accuracy as you have file/some file ID

 

If this is TRUE then you cannot compress the file and load . It defeats the purpose . Uploading a file as single chunk means your file size is small(less than 1 mb) therefore you dont need to compress and you PUT it onto the server by streaming it as an octet stream.

 

you need to Chunk the file into smaller parts and then use gzip application  method 

 

in other words your URL should look like below 

 

/workspaces/{workspaceID}/models/{modelID}/files/{fileId}/chunks/{chunkId} -X --upload-file chunk-aa

 

if you need more info on chunking please refer to 

https://anaplanbulkapi20.docs.apiary.io/#reference/upload-files under Upload a file in chunks

 

 

 

Highlighted
Occasional Contributor

Re: Anaplan restful api uploads with zip files

Oh okay I see. Yes I was doing this as a single chunk. I'll split and try again. Thanks.
Highlighted
Occasional Contributor

Re: Anaplan restful api uploads with zip files

I just tested it out again and splitted a file into the chunks and converted into gzip and it worked,  Thank you.  I had also tested another method:

- I gzip'ed a single file, posted the chunk count of 1,

-Then in my upload url I had to switch it to  {fileid}/chunks/0 ,  instead of the /{fileid}  by itself

- Then uploaded it with a single gzip compressed file.

And it worked! 

 

Thanks!

Highlighted
Master Anaplanner/Community Boss

Re: Anaplan restful api uploads with zip files

glad it worked
uploading a single compressed file as 1 chunk will work as well but its not recommended as it puts load on the server and if if ur upload fails you will have to reupload the entire file.