This Python script automates the import of tasks (work packages) into a self-hosted OpenProject instance using the OpenProject REST API (v3). It reads a CSV file containing task details and posts them into the specified OpenProject project.
Key features:
- Reads any user-provided CSV file containing
Subject,Description,Status, andPrioritycolumns. - Authenticates using OpenProject API tokens (passed as Basic Auth with username
apikey). - Loops through all CSV rows and creates work packages (usually of type
Task). - Provides basic error checking and API connectivity validation.
- Python 3.7 or higher
- Python packages:
requestspandas
These can be installed with:
pip install requests pandas- Prompts the user for:
- OpenProject URL (e.g., http://openproject.local)
- OpenProject API token (generated from your user account page)
- Numeric Project ID (e.g., 3)
- Full path to the CSV file (e.g., D:/path/to/progress_import_ready.csv)
- Checks if the CSV file exists and loads it.
- Validates the API token by making a test GET request.
- Iterates over each row and posts a new work package via the API.
- Prints success or failure messages for each imported item.
Your CSV should include at least the following columns:
SubjectDescriptionStatus(e.g., "New", "In Progress", "Closed")Priority(e.g., "Normal", "High", "Low")
To run this in an air-gapped environment as a standalone executable:
1️ Install PyInstaller (on a machine with internet access):
pip install pyinstaller2️ Build the executable:
pyinstaller --onefile --name openproject_importer import_script.py3️ After building, locate the generated executable inside the dist/ folder:
dist/openproject_importer.exe
4️ Transfer the executable and the CSV file to the air-gapped system.
5️ Run the executable:
openproject_importer.exe6️ Follow the prompts to enter your OpenProject connection details and import tasks.
- The script relies on the OpenProject REST API v3.
- API token authentication uses the
apikeyuser name (per OpenProject documentation). - Make sure the target OpenProject project allows API access and that the token has sufficient permissions.
- If needed, adjust the
typevalue in the script (default is1forTask).
For enhancements (such as better error handling, additional field mappings, or logging), feel free to contact or extend the script!