Skip to content

Commit 3fea1f4

Browse files
authored
dont inject content type on empty body (#2079)
1 parent a4d5b66 commit 3fea1f4

File tree

2 files changed

+2
-2
lines changed
  • .generator/src/generator/templates
  • src/datadog_api_client

2 files changed

+2
-2
lines changed

.generator/src/generator/templates/rest.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class RESTClientObject:
150150
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
151151
if method in ("POST", "PUT", "PATCH", "OPTIONS", "DELETE"):
152152
# Only set a default Content-Type for POST, PUT, PATCH and OPTIONS requests
153-
if method != "DELETE" and "Content-Type" not in headers:
153+
if method != "DELETE" and "Content-Type" not in headers and body is not None:
154154
headers["Content-Type"] = "application/json"
155155
if query_params:
156156
url += "?" + urlencode(query_params)

src/datadog_api_client/rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def request(
152152
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
153153
if method in ("POST", "PUT", "PATCH", "OPTIONS", "DELETE"):
154154
# Only set a default Content-Type for POST, PUT, PATCH and OPTIONS requests
155-
if method != "DELETE" and "Content-Type" not in headers:
155+
if method != "DELETE" and "Content-Type" not in headers and body is not None:
156156
headers["Content-Type"] = "application/json"
157157
if query_params:
158158
url += "?" + urlencode(query_params)

0 commit comments

Comments
 (0)