andygrunwald / go-gerrit

Go client/library for Gerrit Code Review
https://godoc.org/github.com/andygrunwald/go-gerrit
MIT License
94 stars 41 forks source link

Fix ChangeFileContentInChangeEdit function error #158

Open jackbai233 opened 8 months ago

jackbai233 commented 8 months ago

os:

desc:

When I try to use the ChangeFileContentInChangeEdit function to update (or create) file in the remote gerrit server, although no error is reported, the local update content cannot be uploaded to the remote file. After I used chrome developer tools to manually debug and compare, I found that it was an api request header problem:here. After setting the request header to be the same as in chrome:

req.Header.Add("Accept", "*/*")
req.Header.Add("Content-Type", "text/plain")

or delete the json setting:

// req.Header.Add("Accept", "application/json")
// req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

then call this function, the file content can be updated remote server normally.