diff --git a/.generator/src/generator/templates/rest.j2 b/.generator/src/generator/templates/rest.j2 index eb364a126c..65b9540f0d 100644 --- a/.generator/src/generator/templates/rest.j2 +++ b/.generator/src/generator/templates/rest.j2 @@ -150,7 +150,7 @@ class RESTClientObject: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ("POST", "PUT", "PATCH", "OPTIONS", "DELETE"): # Only set a default Content-Type for POST, PUT, PATCH and OPTIONS requests - if method != "DELETE" and "Content-Type" not in headers: + if method != "DELETE" and "Content-Type" not in headers and body is not None: headers["Content-Type"] = "application/json" if query_params: url += "?" + urlencode(query_params) diff --git a/src/datadog_api_client/rest.py b/src/datadog_api_client/rest.py index a3a6e9b330..d8a5376b22 100644 --- a/src/datadog_api_client/rest.py +++ b/src/datadog_api_client/rest.py @@ -152,7 +152,7 @@ def request( # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ("POST", "PUT", "PATCH", "OPTIONS", "DELETE"): # Only set a default Content-Type for POST, PUT, PATCH and OPTIONS requests - if method != "DELETE" and "Content-Type" not in headers: + if method != "DELETE" and "Content-Type" not in headers and body is not None: headers["Content-Type"] = "application/json" if query_params: url += "?" + urlencode(query_params)