Community Boss

Re: Uploading file Via REST API and Triggering Imports

If you upload as user A then run the import as user B then that import will not access user A's upload - they are isolated by user, with the only exception being a default copy which can only be set by an uploading admin in the UI. You need to invoke the import as user A, which is usually done using the API straight after the upload.

If you require an import to be runnable by alternate users from the UI then have the API upload process import into a staging area (module/lists) and source the UI import from that.



Re: Uploading file Via REST API and Triggering Imports


I've attached the code and additional details. any ideas why the upload file is not being picked up?

Community Boss

Re: Uploading file Via REST API and Triggering Imports

I think Ben is in the right,it has to do with file isolation for users,  but it is definitely possible for an import to be set up by a user and run via the API from Anaplan user. I've done this recently albeit with Anaplan Connect, but it should be the same.

In that example, we have made the data source (third tab of the action panel) available to everyone.

Can you try it this way ?


it has no security impact: users can't access the data sources, only WSA can


Nathan Rudman
Anaplan Model Builder

Re: Uploading file Via REST API and Triggering Imports



This works...been on this for 2 days! thanks a million. 


I did the following:


1. Clicked on "Import Data Sources" --> New Source --> Upload New file



2. Selected my file, set permission to "Admins Only" and complete the file upload




[#1 and #2 done with my email account via browser]


#3 and on wards uses the integration account  


3. As a test, I triggered a file download via the REST API and was able to download the file I uploaded via the Browser...Good!


4. Perform an update via the REST API:





 htt ps://api.anaplan.com/2/0/workspaces/xx/models/xxxxxx/files/ActivityLog_POC_ui_upload_20190917_v2.txt







contentTypeValue: application/octet-stream
Data Size: 1075
Begin File upload...
Upload request done. Took: 00:00:00.914
Response Code: 204
File Uploaded!!




One thing to note here is that the API will not take the File ID even though the documentation states send the file id. I got a 404 error when i tried htt ps://api.anaplan.com/2/0/workspaces/xx/models/4xx/files/113000000042



Upload a single chunk

  • Request
curl -X PUT \
https://api.anaplan.com/2/0/workspaces/8a8196b15b7dbae6015b8694411d13fe/models/75A40874E6B64FA3AE0743278996850F/files/113000000008 \
-H 'authorization: AnaplanAuthToken {auth_token}' \
-H "Content-Type:application/octet-stream" --upload-file Tests.txt


5. Ran File down via REST API and was able to download the file i uploaded in #4..good!


6. Ran the Import Task via REST API and data successfully loaded to list!




00:37:26.616 [main] INFO com.fw.xx.anaplan.restapi.client.Task - Run status: Complete. (100.0%)
00:37:26.617 [main] INFO com.fw.xx.anaplan.restapi.client.logging.LogUtils - -----------------------------------------
00:37:26.617 [main] INFO com.fw.xx.anaplan.restapi.client.Task - <<< The operation was successful >>>  =)
00:37:26.617 [main] INFO com.fw.xx.anaplan.restapi.client.logging.LogUtils - - - - - - - - - - - - - - - - - - - - - - 
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - Activity Log: 41 (41/0) rows successful, 0 ignored 
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - hierarchyName - Activity Log
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - successRowCount - 41
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - successCreateCount - 41
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - successUpdateCount - 0
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - warningsRowCount - 0
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - warningsCreateCount - 0
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - warningsUpdateCount - 0
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - failedCount - 0
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - ignoredCount - 0
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - totalRowCount - 41
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - totalCreateCount - 41
00:37:26.631 [main] INFO com.fw.xx.anaplan.restapi.client.Task - totalUpdateCount - 0
00:37:26.632 [main] INFO com.fw.xx.anaplan.restapi.client.Task - invalidCount - 0
00:37:26.632 [main] INFO com.fw.xx.anaplan.restapi.client.Task - updatedCount - 0
00:37:26.645 [main] INFO com.fw.xx.anaplan.restapi.client.Task - renamedCount - 0
00:37:26.646 [main] INFO com.fw.xx.anaplan.restapi.client.Task - createdCount - 41
00:37:26.646 [main] INFO com.fw.xx.anaplan.restapi.client.Task - Task ID 40B850F76B454418B43BB4FA7C4375FF executed by anaplanfrsysdev Complete. Took: 00:00:01.354




Next Steps:


This is a single file upload which will work for most cases however I have several use cases where I need to upload very large data files ( >100 MB) so will need to use chunking...Will test the Chunk APIs next


Community Boss

Re: Uploading file Via REST API and Triggering Imports

great !
Nathan Rudman
Anaplan Model Builder