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

All DELETE api calls returns error 400 (Bad request) #76

Closed
priteshpagar93 opened this issue Dec 31, 2019 · 5 comments · Fixed by #91
Closed

All DELETE api calls returns error 400 (Bad request) #76

priteshpagar93 opened this issue Dec 31, 2019 · 5 comments · Fixed by #91

Comments

@priteshpagar93
Copy link

priteshpagar93 commented Dec 31, 2019

Functions ChangesService.DeleteTopic, ChangesService.DeleteDraftChange returns error '400 Bad Requests'.

RCA:

In function NewRequest (inside gerrit.go), we set following headers:
Accept: application/json
Content-Type: application/json

This works for GET, POST api calls.
But as DELETE api calls does not need any content-type, they return 400.

@xobotyi
Copy link
Contributor

xobotyi commented Jul 16, 2021

Same stuff for Changes.DeleteReviewer

@andygrunwald
Copy link
Owner

Hey @priteshpagar93 and @xobotyi,

can you provide

  • which Gerrit version?
  • a piece of example code to reproduce the issue?

Thanks

@xobotyi
Copy link
Contributor

xobotyi commented Jul 19, 2021

@andygrunwald

  • gerrit is 3.2.6
  • example is pretty straightforward
g, err := gerrit.NewClient(host, nil)
if err != nil {
	panic(err)
}

g.Authentication.SetBasicAuth(username, password)

if _, _, err := g.Access.ListAccessRights(nil); err != nil {
	panic(err)
}

if _, err := g.Changes.DeleteReviewer("existing change id", "account id that set as reviewer"); err != nil {
	panic(err)
}

@xobotyi
Copy link
Contributor

xobotyi commented Jul 25, 2021

@andygrunwald made a PR fixing the issue

andygrunwald added a commit that referenced this issue Jul 26, 2021
* fix: no need to send content-type header if no header sent

close: #76

* Update gerrit.go

Co-authored-by: Andy Grunwald <[email protected]>
@andygrunwald
Copy link
Owner

Thanks both

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

Successfully merging a pull request may close this issue.

3 participants