Creating a ticket in OpenProject using API

vijay chandamala
2 min readJul 29, 2021
Image source: openproject-8–2–6d224276.jpg (1500×1000)

I know most people use JIRA and other familiar tools for project management, but, OpenProject — open source project management software was my first ever project management tool and goodness sake it’s OpenSource!

Well, it’s all there in OpenProject’s docs but I’m just trying to make it simpler and put it here hoping it can save you some time.

Let’s dive right into what you’re actually here for!

The API endpoint :

/api/v3/work_packages

The JSON payload :

{
"subject": "My first ever ticket", ### ticket name
"description": {
"format": "markdown",
"raw": " Description of my ticket", ### ticket description
"html": ""
},
"_links": {
"project": {
"href": "/api/v3/projects/3" ### your project id
},
"type": {
"href": "/api/v3/types/8" ### type,like task, bug etc..
},
"assignee": {
"href": "/api/v3/users/3" ### assign it to someone
},
"responsible": {
"href": "/api/v3/users/3" ### accountable person
}
}
}

The Auth token :

There are multiple ways openproject allows you to do it, since there are multiple ways you can setup authorization for your installation of OpenProject. you can pick any of these auth-types .

I’ll be using basic-auth here. Create an access token (API token) from manage account :

You can use the same while using authorization header with a key-value pair , key named “apikey” and the value will be your access token.

And do make sure the user for which you created the access token for has the project access within which you want to create the ticket.

POST your request :

It depends how you want to post a request to the API, if it’s within your python code you can use requests module or if it’s a simple shell script here’s a curl command :

curl --location --request POST 'http://YOUROPENPROJCTURL/api/v3/work_packages' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic YOURAPITOKENGOESHERE' \
--data-raw '{
"subject": "My first ever ticket",
"description": {
"format": "markdown",
"raw": " Description of my ticket",
"html": ""
},
"_links": {
"project": {
"href": "/api/v3/projects/3"
},
"type": {
"href": "/api/v3/types/8"
},
"assignee": {
"href": "/api/v3/users/3"
},
"responsible": {
"href": "/api/v3/users/3"
}
}
}'

There are many other things you can define in your payload based on which you can select multiple things while creating the ticket.

In order to see possible payload options you can send an empty json to :

/api/v3/work_packages/form

which will provide you the schema and the options.

Here’s the official doc on how to do it : Example (openproject.org)

Have a great day !

--

--