You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not great at github so I don't know if I'm reading this stuff right but somehow the visitoractivites handles bulk export. I coudn't get it to work, so intead I used the PardotAPI's get function to get the visitor activities after setting up the job. The issue with the get function for me is that it only handles json and the bulk export comes in csv, so I had to modify _check_response. Thus I made this, which seems to work. I'm sure there's a more professional version of this.
from pypardot.client import PardotAPI
from pypardot.errors import PardotAPIError
"""
Hello. I had to make this bs because the original pypardot doesn't have the ability to handle csv so I made my own item here.
"""
class KobePardotAPI(PardotAPI):
@staticmethod
def _check_response(response):
"""
Checks the HTTP response to see if it contains JSON. If it does, checks the JSON for error codes and messages.
Raises PardotAPIError if an error was found. If no error was found, returns the JSON. If JSON was not found,
returns the response status code.
"""
if response.headers.get('content-type') == 'application/json':
json = response.json()
error = json.get('err')
if error:
raise PardotAPIError(json_response=json)
return json
elif response.headers.get('content-type') == 'text/csv; charset=utf-8':
return response.text
else: return response
The text was updated successfully, but these errors were encountered:
Hello.
I'm not great at github so I don't know if I'm reading this stuff right but somehow the visitoractivites handles bulk export. I coudn't get it to work, so intead I used the PardotAPI's get function to get the visitor activities after setting up the job. The issue with the get function for me is that it only handles json and the bulk export comes in csv, so I had to modify _check_response. Thus I made this, which seems to work. I'm sure there's a more professional version of this.
from pypardot.client import PardotAPI
from pypardot.errors import PardotAPIError
"""
Hello. I had to make this bs because the original pypardot doesn't have the ability to handle csv so I made my own item here.
"""
class KobePardotAPI(PardotAPI):
@staticmethod
def _check_response(response):
"""
Checks the HTTP response to see if it contains JSON. If it does, checks the JSON for error codes and messages.
Raises PardotAPIError if an error was found. If no error was found, returns the JSON. If JSON was not found,
returns the response status code.
"""
if response.headers.get('content-type') == 'application/json':
json = response.json()
error = json.get('err')
if error:
raise PardotAPIError(json_response=json)
return json
elif response.headers.get('content-type') == 'text/csv; charset=utf-8':
return response.text
else: return response
The text was updated successfully, but these errors were encountered: