Anaplan REST - issue uploading file




I'm not Anaplan guy but doing an integation with Anaplan through the REST API.


Export of data works fine.


Issues come with the import. As first step, we have to upload the file.


We are using PowerShell but any feedback if other language is also welcome.


My question is: shall we use --upload-file in the url. In the API guide I can see xxx is the import file name. This is what we get from files REST resource:


id : 113000000010
name : Import to FDMEE template
chunkCount : 1
delimiter : "
encoding : ISO-8859-1
firstDataRow : 2
format : txt
headerRow : 1
separator : ,


Error when uploading --upload-file xxx
Invoke-RestMethod :

@import "lib/dojo/resources/dojo.css";
html {
overflow: auto;
An error has occurred whilst processing your request:

Not Found
Please close your browser window and try again.
If the problem persists then please contact Anaplan Support.

At C:\REST_Tester_Import.ps1:199 char:17
+ ... tResponse = Invoke-RestMethod -Uri $uri -Method Put -InFile $csvImpor ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand


  • An answer to this would be great. Following along in the apiary docs... there are two URLs listed in the Python example for the mock workspace: 

     values = """ curl --upload-file Tests.txt"""

    headers = { 'Authorization': 'Basic encoded_username:password',

                       'Content-Type': 'application/octet-stream'


    request = Request('{workspaceID}/models/{modelID}/files/{fileId} --upload-file Tests.txt', data=values, headers=headers) request.get_method = lambda: 'PUT'


    response_body = urlopen(request).read()

    print response_body


    Do we ping the site twice? Or as shown here?

    Can't get it to work in my script because only have an So am I pinging my us1a server twice? Or and then us1a?

    Does the --upload-file Test.txt belong in both url calls? 

    @famores, have you solved this? 

    For Anaplan: an upgrade to urllib3 would be great in the docs as urllib2 is no longer the hotness. 



  • s9urom

    I couldn't get it to work either. 


    Finally resolved to go the curl route


    def uploadFileCurl(workspaceId, modelId, fileId, localFileName, remoteFileName) :
        curlcmd = """
        curl -v --include \
            --request PUT \
            --header "Authorization: $cer" \
            --header "Content-Type: application/octet-stream" \
            --data-binary '@$localfile' \
            "$workspaceId/models/$modelId/files/$fileId --upload-file $filename"
        s = Template(curlcmd)
        cmdstr = s.substitute( cer=cer, localfile=localFileName, workspaceId=workspaceId, modelId=modelId, fileId=fileId, filename=remoteFileName )
        print("Command to execute is [" + cmdstr + "]")

  • I wanted to note on this, I checked our Apiary documentation and I see syntax for cURL requests for uploading files is not what I would expect. As noted above, --data-binary is the correct option to use for local files; altnernatively, if you're passing in raw data you would use --data.


    I will follow up with our documentation team to ensure this is corrected as soon as possible.


    Thanks for pointing this out!

  • No. --upload-file is a parameter specific to the cURL utility to tell it to use the specified file as the request body. It looks like you're acheiving this using "-Method Put -InFile <file>" with the tool you're using.
  • Hello


    I am sharing blog URL of informatica read rest api task, where the complete task is discussed in proper way with step by step. Check it out here,

    Hope it will be helpful.


  • Hello


    I am sharing blog URL of Informatica read rest API task, where the complete task is discussed in proper way with step by step. Check it out here,

    Hope it will be helpful.