From 9d03aa66303fc50bbe5029ded7c181e302f51ff1 Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 12 Jun 2024 11:08:32 -0400 Subject: [PATCH] add the json content type header automatically if data is set since we only support json data at the moment w/ burnettk --- src/connector_http/http_request_base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/connector_http/http_request_base.py b/src/connector_http/http_request_base.py index ed86048..83b1682 100644 --- a/src/connector_http/http_request_base.py +++ b/src/connector_http/http_request_base.py @@ -1,6 +1,7 @@ import json import time from collections.abc import Callable +from typing import Any import requests # type: ignore import xmltodict @@ -71,7 +72,7 @@ class HttpRequestBase: try: log(f"Will call {self.url}") - arguments = { + arguments: dict[str, Any] = { "url": self.url, "headers": self.headers, "auth": auth, @@ -80,6 +81,8 @@ class HttpRequestBase: if self.params is not None: arguments["params"] = self.params if self.data is not None: + if not arguments["headers"].keys().include("Content-Type", "Content-type"): + arguments["headers"]["Content-Type"] = "application/json" arguments["json"] = self.data http_response = request_function(**arguments) log(f"Did call {self.url}")