Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RemoveWatcher throws 400 error due to missing query parameter #624

Open
davidnortonjr-sps opened this issue Apr 7, 2023 · 0 comments
Open

Comments

@davidnortonjr-sps
Copy link

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 to the DELETE call, however the API docs indicate is should be in a query parameter 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant