Skip to content

Commit

Permalink
Add back json.dumps_str and always set force_include_body to True
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsvante committed Apr 25, 2021
1 parent b144612 commit a8e537f
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions netsuite/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def __init__(
self._token_id = token_id
self._token_secret = token_secret
self._hostname = self._make_hostname()
self._auth = self._make_auth()
self._default_timeout = default_timeout
self._request_semaphore = asyncio.Semaphore(concurrent_requests)

Expand Down Expand Up @@ -147,11 +146,10 @@ async def _raw_request(
url = self._make_url(subpath)
headers = {**self._make_default_headers(), **request_kw.pop("headers", {})}

auth = request_kw.pop("auth", self._auth)
timeout = request_kw.pop("timeout", self._default_timeout)

if "json" in request_kw:
auth = self._make_auth(force_include_body=True)
request_kw["data"] = json.dumps_str(request_kw.pop("json"))

kw = {**request_kw}
logger.debug(
Expand All @@ -164,7 +162,7 @@ async def _raw_request(
method=method,
url=url,
headers=headers,
auth=auth,
auth=self._make_auth(),
timeout=timeout,
**kw,
)
Expand All @@ -183,14 +181,14 @@ def _make_hostname(self):
def _make_url(self, subpath: str):
return f"https://{self._hostname}/services/rest{subpath}"

def _make_auth(self, force_include_body: bool = False):
def _make_auth(self):
return OAuth1Auth(
client_id=self._consumer_key,
client_secret=self._consumer_secret,
token=self._token_id,
token_secret=self._token_secret,
realm=self._account,
force_include_body=force_include_body
force_include_body=True,
)

def _make_default_headers(self):
Expand Down

0 comments on commit a8e537f

Please sign in to comment.