From dc5e3903308ba718ba4c33f7265eea2ce5c22840 Mon Sep 17 00:00:00 2001 From: Martijn Pieters Date: Fri, 6 Oct 2023 14:43:37 +0100 Subject: [PATCH] Leave JSON encoding to HTTPX 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. --- src/onepasswordconnectsdk/async_client.py | 5 ++--- src/onepasswordconnectsdk/client.py | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/onepasswordconnectsdk/async_client.py b/src/onepasswordconnectsdk/async_client.py index 7df6ad1..f7e357b 100644 --- a/src/onepasswordconnectsdk/async_client.py +++ b/src/onepasswordconnectsdk/async_client.py @@ -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 @@ -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 diff --git a/src/onepasswordconnectsdk/client.py b/src/onepasswordconnectsdk/client.py index a62bae1..2b40327 100644 --- a/src/onepasswordconnectsdk/client.py +++ b/src/onepasswordconnectsdk/client.py @@ -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