Post

2 followers Follow
0
Avatar

REST API Update WorkItemHierarchyLink

I've tried the following:

* Delete and create

* Update existing

The first fails because I cannot convert the item to a to do list because it has logged time (this is probably local config).  The second fails because it says I cannot update the parent once an item is created.

The UI allows this, what am I doing wrong?

Jacob Answered

Official comment

Avatar

Hi Jacob,

Can you please describe the exact scenario you are trying to achieve? Can you give an example?

 

Thanks

 

Elad Franklin

Please sign in to leave a comment.

11 comments

0
Avatar

Task 1234 has parent Task 5678.  I want to change Task 1234 parent to Task ABCD.

I am attempting to do this:

* using a push of a WorkItemHierarchyLink with a new parent and child set using the ID I find with a query.

* deleting the existing WIHL entity and creating a new one.

Jacob 0 votes
0
Avatar

Thanks for the quick response Jacob.

Can you please share the requests you are sending so I can try to reproduce your issue?

 

Elad

Elad Franklin 0 votes
0
Avatar

curl -H "Authorization: Session XXXXX" https://api2.clarizen.com/v2.0/services/data/objects/WorkItemHierarchyLink/YYYYY -d "{child: '/Task/AAAA', parent: '/Task/BBBB'}"

And the results:

{"errorCode":"InvalidOperation","message":"Invalid operation: Field 'Child' can only be updated when the entity is created.","referenceId":"13xHw84Q9w0nNJa1Ev8Zoj"}

The other complains on the delete based on what I think is custom validation in our setup so I haven't done it.

Jacob 0 votes
0
Avatar

[General] Task 'TASK NAME' cannot be converted to a to do list item because it has one or more children or it being use as a shortcut in a project is the other error I'm getting.

Jacob 0 votes
0
Avatar

Hi Jacob,

I did some research and I think that this action will not give you the results you want.

To make the scenario clear and simple, are you trying to move work items from one parent to the other?

 

Elad

Elad Franklin 0 votes
0
Avatar

Hi Jacob,

If this is the scenario you can use the objects endpoint (https://api2.clarizen.com/V2.0/services/data/objects), POST method, to update the parent field.

For example:

URL:https://api2.clarizen.com/V2.0/services/data/objects/Project/xxxx-xxxx-xxxx-xxxx

Method:POST

Body:

{
         'Parent':'/Project/5fcaf951-f432-417c-96b1-c406132afdf9_1'
}

 

This will change the xxxx project's parent.

 

I hope this helps,

 

Elad

 

Elad Franklin 0 votes
0
Avatar

Getting an error message back attempting to change the parent of a task:

[InvalidOperation] Invalid operation: Field 'Parent' can only be updated when the entity is created. (Reference Id: R3mJTm4HCKZZan54lGXrS)

Ideas?

Jacob 0 votes
0
Avatar

Hi Jacob,

I found the solution, in a case you want to change the parent of a work item you need to delete the existing RealWorkItemHierarchyLink and create a new one.

For example:

Method:DELETE 

URL: data/objects/RealWorkItemHierarchyLink/5g58xe2k4lumipju7uf6uz5ht2

 

and then create the new RealWorkItemHierarchyLink :

Method: PUT

URL: data/objects/RealWorkItemHierarchyLink

Body:

{
   "Child": "/Project/9i6ydsvjmta9qrzffhj2i4m511",
   "Parent": "/Project/9i6ydsvjmta9qrzffhj2i4m50"
}

 

I hope this will solve your problem

Elad Franklin 0 votes
0
Avatar

When doing that I am getting:

[General] Task 'TASK NAME' cannot be converted to a to do list item because it has one or more children or it being use as a shortcut in a project

The UI manages to accomplish this, is there another way?

Jacob 0 votes