1

I'm trying to move a subtask from one parent to another. I could change the tasks name with such a PATCH query:

PATCH /sites/PWA/_api/ProjectServer/Projects('4b951130-e0b9-e911-910f-001dd8b71c8d')/Draft/Tasks('af5369a8-e0b9-e911-910f-001dd8b71c8d') HTTP/1.1
Host: [host]
Accept: application/json
X-RequestDigest: [digest]
Content-Type: application/json
Authorization: Basic cG93ZAJtXFNpbWFcaW5fRFY6U2ltMHkxMjE3
User-Agent: PostmanRuntime/7.15.2
Cache-Control: no-cache
Postman-Token: 87937c7f-b10f-4537-9a87-957376a53f01,5535333f-4059-4d79-a335-6b4cb1739896
Host: [host]
Accept-Encoding: gzip, deflate
Content-Length: 56
Connection: keep-alive
cache-control: no-cache

{
    "Name":"NewName"
}

It worked, but when I am trying to change the parent id:

{
    "Name":"NewName",
    "ParentId":"5b5369a8-e0b9-e911-910f-001dd8b71c8d"
}

Only the name changes, it seems that it just ignores the ParentId, but when creating, not updating a subtask with the ParentId parameter everything worked fine.

What is wrong with my query? Why does it allow to create a task with parent id and does not update it?

PS. I've also tried to use ParentIDId instead of ParentId, but it worked neither.

Also, tried to pass this id instead of guid to ParentIDId, but again, only the name has changed: enter image description here

{
    "Name":"NewName",
    "ParentIDId":"5"
}
  • Have you tried passing Item Id of Main/Parent task in you Post/Update query like: { '__metadata': { 'type': 'SP.Data.TaskListItem'}, 'Title': 'Subtask Title', 'ParentIDId':ParentTaskItemId }. Where ParentTaskItemId is list item id of main/parent task. – Ganesh Sanap Aug 29 '19 at 8:14
1

Probably, you just missed a comma in the JSON between fields:

{
    "Name":"NewName",
    "ParentId":"5b5369a8-e0b9-e911-910f-001dd8b71c8d"
}

Also, as far as I remember the ParentID is a lookup field, so the body should be like this:

{
    "Name":"NewName",
    "ParentIDId":5 
}

Where 5 is an ID of the new parent.

| improve this answer | |
  • 1
    Oops, I've missed the comma just in the question, the syntax of the actual request was correct. – user3252040 Aug 29 '19 at 8:23
  • I've tried to pass id from list instead of guid, but again only the name changes. By the way, I've passed guid to ParentId when creating the subtask and it worked fine. – user3252040 Aug 29 '19 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.