add the json content type header automatically if data is set since we only support json data at the moment w/ burnettk
This commit is contained in:
parent
31e76be874
commit
9d03aa6630
|
@ -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}")
|
||||
|
|
Loading…
Reference in New Issue