andygrunwald / andygrunwald/go-jira

RemoveWatcher throws 400 error due to missing query parameter

オープン
#624 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Go
スター
1.6k
フォーク
500
PR マージ指標
30日以内にマージされた PR はありません

説明

## What happened?

When I call client.Issue.RemoveWatcher, I get a HTTP 400 response.

## What did you expect to happen?

For the call to succeed.

## How can we reproduce it (as minimally and precisely as possible)?

```
_, _ = client.Issue.RemoveWatcher(issue.ID, "user@example.com")
```

## Anything else we need to know?

The code seems to [pass the username as the body](https://github.com/andygrunwald/go-jira/blob/main/onpremise/issue.go#L1412) to the DELETE call, however the [API docs indicate is should be in a query parameter](https://docs.atlassian.com/software/jira/docs/api/REST/9.7.0/#api/2/issue-removeWatcher) named `username`.

I was able to resolve it with my own function:

```
func removeWatcher(client *jira.Client, issueID string, username string) error {
apiEndPoint := fmt.Sprintf("rest/api/2/issue/%s/watchers?username=%s", issueID, url.QueryEscape(username))

req, err := client.NewRequestWithContext(context.TODO(), "DELETE", apiEndPoint, nil)
if err != nil {
return err
}

resp, err := client.Do(req, nil)
if err != nil {
err = jira.NewJiraError(resp, err)
}

return err
}

```

## Your Environment

Include as many relevant details about the environment you experienced the problem in

* go-jira version (git tag or sha): `1.16.0`
* Go version (`go version`): `go version go1.19.6 darwin/arm64`
* Jira type (cloud or on-premise): on-prem
* Jira version / Api version: `v9.6.0#960000-sha1:a3ee8af`

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。