Skip to content

Commit

Permalink
add the json content type header automatically if data is set since w…
Browse files Browse the repository at this point in the history
…e only support json data at the moment w/ burnettk
  • Loading branch information
jasquat committed Jun 12, 2024
1 parent 31e76be commit 9d03aa6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/connector_http/http_request_base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import time
from collections.abc import Callable
from typing import Any

import requests # type: ignore
import xmltodict
Expand Down Expand Up @@ -71,7 +72,7 @@ def log(msg: str) -> None:

try:
log(f"Will call {self.url}")
arguments = {
arguments: dict[str, Any] = {
"url": self.url,
"headers": self.headers,
"auth": auth,
Expand All @@ -80,6 +81,8 @@ def log(msg: str) -> None:
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}")
Expand Down

0 comments on commit 9d03aa6

Please sign in to comment.