Skip to content

Commit

Permalink
Add support for setting Content-Type header to application/json
Browse files Browse the repository at this point in the history
  • Loading branch information
AsabuHere committed Oct 12, 2023
1 parent 824722d commit 3bc3564
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ func (c *Client) SendRequest(method string, rawURL string, data url.Values,
req.Header.Add("User-Agent", userAgent)

if method == http.MethodPost {
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
_, ok := headers["Content-Type"]
if !ok {
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
}
}

for k, v := range headers {
req.Header.Add(k, fmt.Sprint(v))
}

return c.doWithErr(req)
}

Expand All @@ -147,4 +149,4 @@ func (c *Client) SetAccountSid(sid string) {
// Returns the Account SID.
func (c *Client) AccountSid() string {
return c.accountSid
}
}

0 comments on commit 3bc3564

Please sign in to comment.