0
votes

followed all the documentation as outlined here

https://docs.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

1
NOTE: i am able to view existing comments "GET" request but POST is not doing anything and not honoring my POST body textKingKongCoder
OK, you're following the documentation to a tee. I suspect it's going to be application/json based on the input, have you tried to remove the content-type? Postman shows the same as Curl? I need to think about this, why would the GET work but not the POSTs, do any POSTs work?Jeremy Thompson
@JeremyThompson look at my comment on the below answer, that did work.KingKongCoder

1 Answers

2
votes

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