Skip to content

Commit b519866

Browse files
author
Raphaël Benitte
authored
Merge pull request #34 from sleclercq/fix-content-type-header
fix(request) add application/json content-type header to POST/PUT req…
2 parents 2ed6f06 + 7e90530 commit b519866

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

gitlab.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ func (g *Gitlab) execRequest(method, url string, body []byte) (*http.Response, e
7979
req, err = http.NewRequest(method, url, nil)
8080
}
8181

82+
if method == "POST" || method == "PUT" {
83+
req.Header.Add("Content-Type", "application/json")
84+
}
85+
8286
if err != nil {
8387
panic("Error while building gitlab request")
8488
}
@@ -142,6 +146,11 @@ func (g *Gitlab) buildAndExecRequestRaw(method, url, opaque string, body []byte)
142146
} else {
143147
req, err = http.NewRequest(method, url, nil)
144148
}
149+
150+
if method == "POST" || method == "PUT" {
151+
req.Header.Add("Content-Type", "application/json")
152+
}
153+
145154
if err != nil {
146155
panic("Error while building gitlab request")
147156
}

0 commit comments

Comments
 (0)