Expand my Community achievements bar.

Don’t miss the Workfront AMA: System Smarts & Strategic Starts! Ask your questions about keeping Workfront running smoothly, planning enhancements, reporting, or adoption, and get practical insights from Adobe experts.
SOLVED

Update a comment with rich text HTML via REST API

Avatar

Level 1

I can successfully create a comment (as seen in Workfront UI Updates section) of an Issue with this REST API call using v20

```

curl --location 'https://SUBDOMAIN.workfront.com/attask/api/v20.0/note' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"objID": "68d2c7fe00911872fc05f2e559650090",
"objCode": "NOTE",
"html": "Hello <b>World</b> from Postman JSON 1",
"noteText": "Hello Plain from Postman JSON 1",
"noteObjCode": "OPTASK",
"json": "{}"
}'

```

 

The problem is updating a comment (with or without a nested comment). I can only update the plain text noteText, the HTML is not overwritten. Since Adobe Workfront UI only displays the HTML comment this update is not displaying!!

 

```

curl --location --request PUT 'https://SUBDOMAIN.workfront.com/attask/api/v20.0/note/68d43bd6004d01abe8f85c5726e94108' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"objID": "68d2c7fe00911872fc05f2e559650090",
"objCode": "NOTE",
"html": "Hello <b>World</b> from Postman JSON 2",
"noteText": "Hello Plain from Postman JSON 2",
"noteObjCode": "OPTASK",
"json": "{}"
}'

```

 

I also tried sending the rich text format in Draft.js JSON

```

curl --location --request PUT 'https://SUBDOMAIN.workfront.com/attask/api/v20.0/note/68d43bd6004d01abe8f85c5726e94108' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{
"objID": "68d2c7fe00911872fc05f2e559650090",
"objCode": "NOTE",

"noteObjCode": "OPTASK",
"noteText": "Update 3",
"json": "{\"blocks\":[{\"key\":\"some_random_key\",\"text\":\"Update 3\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}"
}'

```

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 1

I got this to work by reverse engineering the Workfront UI using their GraphQL endpoint

curl --location 'https://SUBDOMAIN.workfront.com/comments/api/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{"variables":{"data":{"commentID":"68d5855900024794261c45be7626bf51","contentHTML":"<p class=\"react-spectrum-RichTextEditor-paragraph\" dir=\"ltr\" style=\"margin: 0px; padding: 0px;\"><span style=\"white-space: pre-wrap;\">Hello 11:13</span></p>","content":"Hello 11:13","tags":[],"attachments":[]}},"query":"mutation ($data: InputEditData) {\n  editComment(data: $data) {\n    attachments {\n      id\n      name\n      type\n      __typename\n    }\n    contentHTML\n    content\n    tags {\n      id\n      objCode\n      __typename\n    }\n    metadata\n    modified\n    modifiedBy\n    lastModifiedAt\n    __typename\n  }\n}"}'

View solution in original post

4 Replies

Avatar

Level 1

Avatar

Level 1

Avatar

Level 7

We used Draft.js to HTML and fixed the text patterns which has paragraph breaks accordingly.

 

 

 

Avatar

Correct answer by
Level 1

I got this to work by reverse engineering the Workfront UI using their GraphQL endpoint

curl --location 'https://SUBDOMAIN.workfront.com/comments/api/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: ••••••' \
--data '{"variables":{"data":{"commentID":"68d5855900024794261c45be7626bf51","contentHTML":"<p class=\"react-spectrum-RichTextEditor-paragraph\" dir=\"ltr\" style=\"margin: 0px; padding: 0px;\"><span style=\"white-space: pre-wrap;\">Hello 11:13</span></p>","content":"Hello 11:13","tags":[],"attachments":[]}},"query":"mutation ($data: InputEditData) {\n  editComment(data: $data) {\n    attachments {\n      id\n      name\n      type\n      __typename\n    }\n    contentHTML\n    content\n    tags {\n      id\n      objCode\n      __typename\n    }\n    metadata\n    modified\n    modifiedBy\n    lastModifiedAt\n    __typename\n  }\n}"}'