添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Your browser is outdated and unsupported. You may run into errors and degraded experience on this page. Please update your browser.

I tried to create a work package though the API by using the following link as POST request:

https://openproject.xxx/api/v3/projects/testprojekt/work_packages

I used the following body:

{"subject": "test", "status": „new“, "type": „bug“, "description": {"format": "textile", "raw": "asd"}}

But unfortunately I get the following error:

"_type": "Error", "errorIdentifier": "urn:openproject-org:api:v3:errors:MultipleErrors", "message": "Einschränkungen für mehrere Felder wurden verletzt.", "_embedded": { "errors": [ "_type": "Error", "errorIdentifier": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation", "message": "Typ muss ausgefüllt werden.", "_embedded": { "details": { "attribute": "type" "_type": "Error", "errorIdentifier": "urn:openproject-org:api:v3:errors:PropertyConstraintViolation", "message": "Typ ist nicht auf einen erlaubten Wert gesetzt.", "_embedded": { "details": { "attribute": "type"

What’s my fault? I’m very sure that the type is correct.
I’m using OpenProject 6.

Thanks for help!

your request is not correct. Please compare with the APIv3 guide: http://opf.github.io/apiv3-doc/#work-packages-work-packages-post

You’ll need to pass the type in the HAL _links section:

"_links": { "type": { "href": "/api/v3/types/1" // Change TYPE ID to your Bug type. Check /api/v3/types for available types // Other LINKED attributes ... "subject": "Foobar", // Other EMBEDDED attributes ...

Best,
Oliver

Hi Oliver,

I tried to create with this code a work packages:

var xhr2 = new XMLHttpRequest();

var data = ‘{subject subject“,”description“: {”format“: ”textile“, ”raw“: ”My raw textile formatted description. Bye guys!“}, ”_links“: {”type“: {”href“:”/api/v3/types/1“, ”title“: ”Task“}, ”status“:{”href“:”/api/v3/statuses/1“}, ”priority“:{”href“:”/api/v3/priorities/8“, ”title“: ”normal“}, ”assignee“: {”href“: ”/api/v3/users/1"}}}}’;

xhr2.open(‘GET’, ‘mydomain/openproject/api/v3/projects/dsds/work_packages/’);
xhr2.setRequestHeader(‘API_KEY’, ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx’);
xhr2.setRequestHeader(‘Content-type’, ‘application/json’);

xhr2.onreadystatechange = function() {
if (xhr2.readyState 4 && xhr2.status 200) {
console.log(xhr2.responseText);
console.log(xhr2.readyState + “-” + xhr2.status);

xhr2.send(data);

Still i only get readyState == 4 and status = 0 in the console. the user admin is existing.

Do you know what the problem is?

Thank you for your help!

Best regards
Otmane