andygrunwald / andygrunwald/go-jira

RemoveWatcher throws 400 error due to missing query parameter

未关闭
#624 0 条评论 0 个 reaction 已指派 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 摘要。