Post

3 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
Comment actions Permalink

Please sign in to leave a comment.

14 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
Comment actions Permalink
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
Comment actions Permalink
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
Comment actions Permalink
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
Comment actions Permalink
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
Comment actions Permalink
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
Comment actions Permalink
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
Comment actions Permalink
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
Comment actions Permalink
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
Comment actions Permalink
0
Avatar

Elad, could I please have an update. This seems like something else in the API that is not feature complete (along with URL fields and being able to specify the text instead of just the URL).  Can you confirm the soap could handle this? I would hate to mix both, but if that's the only option...

Jacob 0 votes
Comment actions Permalink
0
Avatar

Hi Jacob,

Sorry for the late response. It is not an issue with the REST API. I did my research on projects and I missed that you are working with tasks. You are trying to move a Task that probably has child work items or it is a shortcut. I am still researching if this action is available via the API.

I will keep you up to date.

 

Elad

Elad Franklin 0 votes
Comment actions Permalink
0
Avatar

Hi Jacob,

After many tries it seems like it is not supported in the API. The task link to the project cannot be deleted as the Task has child items.

I will continue to find a solution and I will update here if I find one.

 

Elad

Elad Franklin 0 votes
Comment actions Permalink