Content
You are here:
API - 4.2 - Create a work package in a project
Added by Nicolas Vaissaud over 9 years ago
Hello,
I would like to use your API to create a work package and assign it to a project member.
Therefore, my plan is to:
- Get all my project ids (V2 ok api/v2/projects.json?key=MYKEY / V3 NOK ?)
- Get all project members ids (is it possible ? i only get the responsible id in V2 api/v2/projects/12.json?key=MYKEY)
- Create a new work package and assign it to one of the member (looks like you only can update one, no creation endpoint yet ?)
Thank you for your help.
Regards,
Replies (1)
APIv2 is able to update and create work packages.
Determining possible assignees is not supported via APIv2, though.
All development efforts go into APIv3, so I’d advise you to use this one as much as possible.
Since OP 4.2 the APIv3 can also create work packages. APIv3 will also tell you who is a possible assignee/responsible. However, as of now APIv3 can’t give you a list of projects/work packages.
Our documentation on APIv3 can be found here: https://www.openproject.org/api/
The documentation for APIv2 here: https://github.com/opf/openproject/blob/dev/doc/apiv2-documentation.md
The interesting endpoints in APIv3 are:
/api/v3/projects/{id}/work_packages
/api/v3/projects/{id}/available_assignees
(refered to as/api/v3/projects/{id}/work_packages/available_assignees
in the docs… not sure why there is a difference)A note regarding APIv3: It might still be subject to change, but it is a hypermedia API. Therefore changing endpoint URLs don’t have to be a hazzle as long as you try to hardcode as few URLs as possible, but instead “follow” the links in the API responses.
E.g. you do not need to hardcode
/api/v3/projects/{id}/available_assignees
in your client, but instead you can use whatever URL you are pointed to in the corresponding form (e.g. in JSON-Path:_embedded/schema/assignee/allowedValues
).I hope that I could help you.
Best regards
Jan Sandbrink