From f8e09a4a8d062ad0e5b461cbeec0584ffef026d0 Mon Sep 17 00:00:00 2001 From: voyz Date: Fri, 6 Sep 2024 15:51:08 +0200 Subject: [PATCH] restclient lstripps each endpoint from "/" to prevent double forwardslash "//" --- ibind/base/rest_client.py | 1 + test/integration/base/test_rest_client_i.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ibind/base/rest_client.py b/ibind/base/rest_client.py index 9113f50a..bbc5e842 100644 --- a/ibind/base/rest_client.py +++ b/ibind/base/rest_client.py @@ -147,6 +147,7 @@ def request(self, method: str, endpoint: str, attempt: int = 0, log: bool = True Exception: For any other errors that occur during the request. """ + endpoint = endpoint.lstrip("/") url = f"{self.base_url}{endpoint}" # we want to allow default values used by IBKR, so we remove all None parameters diff --git a/test/integration/base/test_rest_client_i.py b/test/integration/base/test_rest_client_i.py index a9ce10c3..a9d5825c 100644 --- a/test/integration/base/test_rest_client_i.py +++ b/test/integration/base/test_rest_client_i.py @@ -26,7 +26,7 @@ def setUp(self): self.response = MagicMock() self.response.json.return_value = self.data - self.default_path = '/test/api/route' + self.default_path = 'test/api/route' self.default_url = f'{self.url}/{self.default_path}' self.result = Result(data=self.data, request={'url': self.default_url}) self.maxDiff = 9999