Pre-optimization commit: Calendar sync implementation with hub design
This commit is contained in:
@@ -133,7 +133,7 @@ class AdvowareAPI:
|
||||
try:
|
||||
self._log(f"Making API call: {method} {url}")
|
||||
async with session.request(method, url, headers=effective_headers, params=params, json=json_data) as response:
|
||||
self._log(f"API response status: {response.status}")
|
||||
response.raise_for_status()
|
||||
if response.status == 401:
|
||||
self._log("401 Unauthorized, refreshing token")
|
||||
token = self.get_access_token(force_refresh=True)
|
||||
@@ -142,7 +142,19 @@ class AdvowareAPI:
|
||||
response.raise_for_status()
|
||||
return await response.json() if response.content_type == 'application/json' else None
|
||||
response.raise_for_status()
|
||||
return await response.json() if response.content_type == 'application/json' else None
|
||||
if response.content_type == 'application/json':
|
||||
try:
|
||||
return await response.json()
|
||||
except Exception as e:
|
||||
self._log(f"JSON parse error: {e}")
|
||||
try:
|
||||
text = await response.text()
|
||||
self._log(f"Response text: {text}")
|
||||
except Exception as text_e:
|
||||
self._log(f"Error getting response text: {text_e}")
|
||||
raise
|
||||
else:
|
||||
return None
|
||||
except aiohttp.ClientError as e:
|
||||
self._log(f"API call failed: {e}")
|
||||
raise
|
||||
|
||||
Reference in New Issue
Block a user