@@ -61,9 +61,20 @@ def _make_request(self, method: str, endpoint: str, **kwargs: Any) -> Dict:
61
61
)
62
62
kwargs ["headers" ] = headers
63
63
64
- response = self ._session .request (method , url , ** kwargs )
65
- response .raise_for_status ()
66
- return response .json ()
64
+ try :
65
+ response = self ._session .request (method , url , ** kwargs )
66
+ response .raise_for_status ()
67
+ return response .json ()
68
+ except requests .exceptions .HTTPError as e :
69
+ logger .error (f"HTTP error occurred: { e } " )
70
+ if e .response .status_code == 404 :
71
+ logger .error (f"Endpoint not found: { url } " )
72
+ if "sync_history" in endpoint :
73
+ logger .info ("Attempting fallback to /sync endpoint" )
74
+ # Try with the correct endpoint
75
+ new_endpoint = endpoint .replace ("sync_history" , "sync" )
76
+ return self ._make_request (method , new_endpoint , ** kwargs )
77
+ raise
67
78
68
79
def list_connectors (self ) -> List [Dict ]:
69
80
"""Retrieve all connectors from the Fivetran API."""
@@ -172,8 +183,9 @@ def list_connector_sync_history(
172
183
since_time = int (time .time ()) - (days * 24 * 60 * 60 )
173
184
params = {"limit" : 100 , "since" : since_time }
174
185
186
+ # Updated to use the correct endpoint
175
187
response = self ._make_request (
176
- "GET" , f"/connectors/{ connector_id } /sync_history " , params = params
188
+ "GET" , f"/connectors/{ connector_id } /sync " , params = params
177
189
)
178
190
179
191
return response .get ("data" , {}).get ("items" , [])
0 commit comments