0
Answer

To add watcher of jira issue in c# with jira rest api

Rui Fan

Rui Fan

8y
718
1

I posted this on a jira rest api forum , but no body answered me , so I POST it here , hope to get help. 

I tried to add a watcher to one JIRA issue, but anyway,  it returns "bad request".

I can update assignee, comment, labels, .... with the similar code below, only watcher got me.

Thanks in advance.

my code is as below:

public void updateJiraWatcher(string key,string watcherName)

var request = new RestRequest()

{

Method=Method.Post,

Resource = "/rest/api/2/issue/"+key+"/watchers",

RequestFormat= DatFormat.JSon

};

string jsonWatcher ="{\""+watcherName+"\"}";  // "{\"username\":\""+watcherName +"\"}; ** doesn't work too

request.AddParameter("application/json",jsonWatcher,ParameterType.RequestBody);

var response = GetRequestsResponse(request);