Skip to content

Commit

Permalink
Leave JSON encoding to HTTPX
Browse files Browse the repository at this point in the history
This ensures that the library also includes any content-type headers, and
avoids a deprecation warning (`Use 'content=<...>' to upload raw
bytes/text content.`) from HTTPX.
  • Loading branch information
mjpieters committed Jan 4, 2024
1 parent bf1c6fa commit dc5e390
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/onepasswordconnectsdk/async_client.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Python AsyncClient for connecting to 1Password Connect"""
import httpx
from httpx import HTTPError
import json
from typing import Dict, List, Union
import os

Expand Down Expand Up @@ -361,8 +360,8 @@ def build_request(self, method: str, path: str, body=None) -> httpx.Response:
"""

if body:
serialized_body = json.dumps(self.serializer.sanitize_for_serialization(body))
response = self.session.request(method, path, data=serialized_body)
sanitized_body = self.serializer.sanitize_for_serialization(body)
response = self.session.request(method, path, json=sanitized_body)
else:
response = self.session.request(method, path)
return response
Expand Down
4 changes: 2 additions & 2 deletions src/onepasswordconnectsdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ def build_request(self, method: str, path: str, body=None) -> httpx.Response:
"""

if body:
serialized_body = json.dumps(self.serializer.sanitize_for_serialization(body))
response = self.session.request(method, path, data=serialized_body)
sanitized_body = self.serializer.sanitize_for_serialization(body)
response = self.session.request(method, path, json=sanitized_body)
else:
response = self.session.request(method, path)
return response
Expand Down

0 comments on commit dc5e390

Please sign in to comment.