RESTAPI : Run a process with an import action
Hi,
I'd like to know if it's possible to run a process with an or several import(s) action in RESTAPI ?
I successed to import data using only an Import action.
As we don't have an example on the documentation, I tried to just change the importTrigger function. I change "/imports/{importID}" (see below within ImportTrigger) by "/processes/{processID}" (see below within processImportTrigger)
I still send the file within Anaplan using SendData function (see below)
But the import doesn't work anymore.
Do you have any idea ?
Thanks
Regards,
Yohan
@classmethod
def sendData(cls, token, wsId, modelId, fileId, chunkCount, content):
# Send the data to Anaplan to update datasource
## First, tell Anaplan API's server it will receive one chunk
headers = {'Authorization': 'AnaplanAuthToken %s' % token, 'Content-Type': 'application/json'}
data = json.dumps({'id': fileId, "chunkCount": chunkCount})
response = requests.post(
urlStem + "/workspaces/" + wsId + "/models/" + modelId + "/files/" + fileId,
headers=headers,
data=data
)
## Now let's send the file
headers2 = {'Authorization': 'AnaplanAuthToken %s' % token, 'Content-Type': 'application/octet-stream'}
response2 = requests.put(
urlStem + "/workspaces/" + wsId + "/models/" + modelId + "/files/" + fileId + "/chunks/" + str(
chunkCount - 1)
,
headers=headers2,
data=content
)
status_code = response2.status_code
return status_code
@classmethod
def importTrigger(cls, token, wsId, modelId, importId):
# Finally we trigger the import
headers = {'Authorization': 'AnaplanAuthToken %s' % token, 'Content-Type': 'application/json'}
data = json.dumps({'localeName': "en_US"})
response = requests.post(
urlStem + "/workspaces/" + wsId + "/models/" + modelId + "/imports/" + importId + "/tasks/",
headers=headers,
data=data
)
# Get the taskId
jsonResponse = json.loads(response.content)
taskId = jsonResponse["task"]["taskId"]
return taskId
classmethod
jsonResponse = json.loads(response.content)
taskId = jsonResponse["task"]["taskId"]
return taskId
Comments
-
yrignac Member, ALL USERS, Partner, Community Member, Certified Model Builder Posts: 5 Occasional ContributorProblem was not on the import function but on sendData.
I've made a small changed with big impact.
Thank you0
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