Anaplan REST - issue uploading file
Hi,
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
https://api.anaplan.com/1/3/workspaces/8a81b08e4f13b5e3014f281bcca564e9/models/883833FE74FA4CE58969ADD043C630CA/files/113000000010 --upload-file xxx
Invoke-RestMethod :
Anaplan
@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
Comments
-
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 https://api.anaplan.com/1/3/workspaces/8a8196b15b7dbae6015b8694411d13fe/models/75A40874E6B64FA3AE0743278996850F/files/113000000008 --upload-file Tests.txt"""
headers = { 'Authorization': 'Basic encoded_username:password',
'Content-Type': 'application/octet-stream'
}
request = Request('https://private-3a7075-anaplan.apiary-mock.com/1/3/workspaces/{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 api.anaplan.com/1/3 site twice? Or as shown here?
Can't get it to work in my script because only have an us1a.app.anaplan.com. So am I pinging my us1a server twice? Or api.anaplan.com 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.Thanks!
0 -
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' \
"https://api.anaplan.com/1/3/workspaces/$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 + "]")
os.system(cmdstr)0 -
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,
https://zappysys.com/blog/read-json-informatica-import-rest-api-json-file/
Hope it will be helpful.
0 -
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,
https://zappysys.com/blog/read-json-informatica-import-rest-api-json-file/
Hope it will be helpful.
0
Categories
- All Categories
- 2.3K Anaplan Community
- Academy
- Anaplan Talent Builder
- Model Design Course
- The Anaplan Way
- Archive
- 2 Idea exchange
- 62 Enterprise Scale
- 1.1K Extensibility
- 21 Intelligence
- 1.6K Planning & Modeling
- 331 Security
- Community Connections
- Connections
- Experiences
- Groups
- Personas
- Employees
- CS Toolkit
- Customer Care Center
- Forums
- Academy & Training
- Community Feedback & Updates
- Japan
- Anaplan Community Japan
- Anaplan Community Japan Knowledge Base
- HyperCare Japan
- JP-Central
- Support-Japanese
- Partners
- Partner Leadership Council
- Partner Product Council
- 724 Platform
- Anapedia
- App Hub
- Centers Of Excellence
- Extensions
- Planual
- Platform Updates
- 724 User Experience
- Profile Builder
- Resources
- Anaplan Advocates
- Anaplan Live!
- Community
- Community Advancement
- Community Connections
- Partner Program
- The Official Master Anaplanner Program
- Videos
- Welcome to the Anaplan Community!
- Success Central
- Support
- Case Portal Link
- Common Support Questions
- HyperCare Redirect
- Known Issues and Workarounds
- Support test page
- SupportFAQ
- Survey
- 2 Training Day Takeaways