KingKongCoder
KingKongCoder

Reputation: 690

Not able to add comment to work items using REST API

followed all the documentation as outlined here

https://learn.microsoft.com/en-us/rest/api/azure/devops/wit/comments/add?view=azure-devops-rest-6.0

but not able to add comments to the work item don't get any useful info in the response, here is my CURL request i am using PAT for authentication.

curl -H "Authorization: Basic {Base64_PAT}" -H "Content-Type: application/x-www-form-urlencoded" -X POST -d '[{"text": "Testing REST API"}]' https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{workItemId}/comments?api-version=6.0-preview.3

i've also tried application/json content type in the header but no use.

this however gives me response of the existing comment but not adding this comment in the body to work item.

Any help is hugely appreciated don't have a clue as what might be happening as i don't get any informative response i get a html response back which has a link and when clicked on it takes me to the response which shows existing comment response body but not adding comment in the POST body to the work item

Upvotes: 2

Views: 1021

Answers (1)

Shamrai Aleksander
Shamrai Aleksander

Reputation: 16133

I`ve tried your example and got the answer:

curl: (3) [globbing] unmatched close brace/bracket in column 17

Try to remove space between

"text":here"Testing

Additionally, there are some issues:

  1. Do not use the square brackets in the requests: Cannot add comments to a work item with API version 5.1-preview3
  2. Escape quotation marks: CouchDB cURL Windows Command Line Invalid JSON

The following works on my windows:

curl -u :<pat> -H "Content-Type: application/json" -X POST -d {"""text""":"""Testing REST API"""} https://dev.azure.com/<org>/<project>/_apis/wit/workItems/<wiid>/comments?api-version=6.0-preview.3

Upvotes: 4

Related Questions