Use this recipe when your source data is in a CSV file and an import action already exists in the model.

You need:

  • An authentication token.
  • Access to the target workspace and model.
  • An existing import action in the model.
  • A model file object associated with the import.
  • A CSV file that matches the import mapping.

To import a CSV to Anaplan with an API:

  1. Authenticate yourself.
    Request: POST https://auth.anaplan.com/token/authenticate
    Save the returned authentication token (Authorization: AnaplanAuthToken {anaplan_auth_token}) to use it in later requests
  2. Find the workspace.
    Request: GET /workspaces
    Save the id of the workspace you want to use as workspaceId.
  3. Find the model.
    Request: GET /workspaces/{workspaceId}/models
    Save the id of the model you want to use as modelId.
  4. Find the import action
    Request: GET /workspaces/{workspaceId}/models/{modelId}/imports
    Save the id of the import action as importId.
  5. Find the source file.
    Request: GET /workspaces/{workspaceId}/models/{modelId}/files
    Save the id of the file used by the import as fileId.
  6. Set the upload chunk count.
    Request: PUT /workspaces/{workspaceId}/models/{modelId}/files/{fileId}/chunks
    Sets the number of chunks you plan to upload. For small files, this may be one chunk. For larger files, split the file into multiple chunks before upload.
  7. Upload each chunk.
    Request: PUT /workspaces/{workspaceId}/models/{modelId}/files/{fileId}/chunks/{chunkId}
    Upload each chunk in order. Note: Use sequential chunk IDs, starting with 0.
  8. Mark the upload complete.
    Request: POST /workspaces/{workspaceId}/models/{modelId}/files/{fileId}/complete
    This tells Anaplan the uploaded file is ready for the import action.
  9. Start the import.
    Request: POST /workspaces/{workspaceId}/models/{modelId}/imports/{importId}/tasks
    Save the returned taskId.
  10. Poll the import task.
    Request: GET /workspaces/{workspaceId}/models/{modelId}/imports/{importId}/tasks/{taskId}
    Repeat this request until the task reaches a terminal state. Do not rely on the task state alone. Inspect the task result to confirm whether records were imported successfully.
  11. Download a failure dump, if needed.
    Request: GET /workspaces/{workspaceId}/models/{modelId}/imports/{importId}/tasks/{taskId}/dump
    Use this request only when the task result indicates that a failure dump is available.

The CSV data is uploaded to the model file object, the import action runs, and the task result shows whether records were successfully imported.

If the import fails, check:

  • Whether the file upload was marked complete.
  • Whether the CSV structure matches the import mapping.
  • Whether the import action uses the expected source file.
  • Whether the integration user can run the import.
  • Whether a failure dump is available.