def get(self, object_name, path=None, params=None, retries=0):
"""
Makes a GET request to the API. Checks for invalid requests that raise PardotAPIErrors. If the API key is
invalid, one re-authentication request is made, in case the key has simply expired. If no errors are raised,
returns either the JSON response, or if no JSON was returned, returns the HTTP response status code.
"""
if params is None:
params = {}
params.update({'user_key': self.user_key, 'api_key': self.api_key, 'format': 'json'})
try:
self._check_auth(object_name=object_name)
request = requests.get(self._full_path(object_name, path), params=params)
response = self._check_response(request)
return response
except PardotAPIError as err:
if err.message == 'Invalid API key or user key':
response = self._handle_expired_api_key(err, retries, 'get', object_name, path, params)
return response
else:
raise err
评论列表
文章目录