-
Notifications
You must be signed in to change notification settings - Fork 94
Description
When calling "get_activities_export_job_status" I receive the error "TypeError: 'Response' object has no attribute 'getitem'".
_Traceback (most recent call last):
File "get_marketo_activities.py", line 107, in
export_job_status = mc.execute(method='get_activities_export_job_status', job_id=exportId)
File "/usr/local/lib/python2.7/site-packages/marketorestpython/client.py", line 254, in execute
result = method_map[method](*args, **kargs)
File "/usr/local/lib/python2.7/site-packages/marketorestpython/client.py", line 4873, in get_activities_export_job_status
return self._export_job_state_machine('activities', 'status', *args, **kargs)
File "/usr/local/lib/python2.7/site-packages/marketorestpython/client.py", line 4859, in export_job_state_machine
if not result['success']:
TypeError: 'Response' object has no attribute 'getitem'
It appears to be related to the mode='nojson' argument in the "_export_job_state_machine" method. The status.json returns as JSON and therefore should NOT set mode='nojson'.
result = self._api_call(
state_info[state]['method'], self.host + '/bulk/v1/{}/export/{}{}'.format(entity, job_id, state_info[state]['suffix']), args, mode='nojson')
When I remove this from _export_job_state_machine" method, it works as expected. Therefore, I was thinking maybe the state_info dict could be updated to include a 'mode' item for each state key and then reference that mode in the result call.
_i.e. state_info = {'enqueue': {'suffix': '/enqueue.json', 'method': 'post', 'mode': 'nojson'}, 'cancel': {'suffix': '/cancel.json', 'method': 'post', 'mode': 'nojson'}, 'status': {'suffix': '/status.json', 'method': 'get', 'mode': ''}, 'file': {'suffix': '/file.json', 'method': 'get', 'mode': 'nojson'}}
result = self.api_call(
state_info[state]['method'], self.host + '/bulk/v1/{}/export/{}{}'.format(entity, job_id, state_info[state]['suffix']), args, mode=state_info[state]['mode'])
Also, I noticed an semantic error in the _export_job_state_machine method. The second assert is duplicated, it should be assert state is not None....
def _export_job_state_machine(self, entity, state, job_id):
assert entity is not None, 'Invalid argument: required fields is none.'
assert entity is not None, 'Invalid argument: required fields is none.'
assert job_id is not None, 'Invalid argument: required fields is none.'