(self, endpoint: str, data: Any = None, params: Any = None)
| 174 | print(f"message: {response.reason}' '{response.status_code}' '{ e }") |
| 175 | |
| 176 | def post(self, endpoint: str, data: Any = None, params: Any = None) -> tuple[int, str]: |
| 177 | headers = { |
| 178 | "Authorization": f"Bearer {self.foundation_client.get_access_token()}", |
| 179 | "Content-type": "application/json", |
| 180 | } |
| 181 | |
| 182 | try: |
| 183 | response = requests.post( |
| 184 | f"{self.baseurl}{endpoint}", headers=headers, params=params or None, data=data or None |
| 185 | ) |
| 186 | |
| 187 | if response.status_code != 201: |
| 188 | response.raise_for_status() |
| 189 | return response.status_code, response.text |
| 190 | except requests.exceptions.HTTPError as errh: |
| 191 | print(f"message: {response.reason}' '{response.status_code}, {errh}") |
| 192 | return response.status_code, response.reason |
| 193 | |
| 194 | def put(self, endpoint: str, data: Any = None, params: Any = None) -> tuple[int, str]: |
| 195 | headers = { |
no test coverage detected