Content
You are here:
[Solved] Work Order created with API are always set with the same Type
Added by Michael Lathion over 9 years ago
Hello,
I’m trying to develop a small application to create work order thru API v3 under Open Project 4.3.0-alpha.
When I send the following request with curl :
curl -u apikey:APIKEY -H “Content-type: application/json” -X POST -d “{”subject“:”monsujet“, ”type“:{”href“:”/api/v3/types/2“,”title“:”Task“}}” https://MYPROJECT.openproject.com/api/v3/projects/2/work_packages
The work order is created with the right subject but with the default type 4 (Milestone) instead of the type 2 Task.
Isn’t that the right way to define the type ?
How should I do ?
Thanks
Replies (2)
Hi,
I have to admit that I ran into this issue myself. You almost got it right though. In order to set linked properties you need to enclose them in _links
Have a look at the 200 response of http://opf.github.io/apiv3-doc/#work-packages-workpackage-get to know how to format properties.
Also: If you found a nice spot to add this as a hint to the APIv3 documentation, don’t hesitate to create a pull request ;)
Regards,
Alex
Hi,
Thanks, I finally found it by myself after some trials and errors (took me about 1 complete day but I’m not an experienced programmer ;) ).
I’ll try to mak a pull request on the documentation, I think the best is to add a remark in the Link object section.
Best regards, and thanks for the good job on this software!
PS: sorry for posting from another account but I have issues connecting with the Google authentification method.