Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

'int' object has no attribute 'get' #20

Open
gcoogle opened this issue Jun 9, 2016 · 4 comments
Open

'int' object has no attribute 'get' #20

gcoogle opened this issue Jun 9, 2016 · 4 comments

Comments

@gcoogle
Copy link

gcoogle commented Jun 9, 2016

When calling the "query" function on an object, I am getting an error on this line:
result = response.get('result')

The error is:

AttributeError: 'int' object has no attribute 'get'

Any idea why this is happening? How to fix it?

I've done online research, but nothing has helped.

@ViolaHempel
Copy link

ViolaHempel commented Jun 9, 2016

Hi @Coogie7,

I've encountered the same error recently. The trick is to make sure you're querying against a non-empty dictionary.

For example, I run this query to get the number of visitor activities in March 2015:

visitoractivities = p.visitoractivities.query(created_after='2015-03-01', created_before='2015-04-01', sort_by='created_at')
total_visitoractivities = visitoractivities['total_results']
print(total_visitoractivities)

I get 460876. To loop through all results, I need to specify the range from 0 to 460800 with a step of 200 like this:

resultList = []

for i in range(0,460800, 200):
    data = p.visitoractivities.query(created_after='2015-03-01', created_before='2015-04-01', offset= i, sort_by='created_at')
    va = data['visitor_activity']
    for item in va:
        resultList.append(item)

va_df = pd.DataFrame(resultList)

If I set a larger range, I'll get the attribute error as you describe. Hope this helps!

-Viola

@gcoogle
Copy link
Author

gcoogle commented Jun 9, 2016

What if I'm querying an object with only 20 records? The offset itsn't needed in this case. I know the API limits a call to 200 records.

@ViolaHempel
Copy link

Not sure about that. Do you have the latest version from git installed?

pip uninstall pypardot
pip install -e git+https://github.com/joshgeller/PyPardot.git#egg=PyPardot

@gcoogle
Copy link
Author

gcoogle commented Jun 9, 2016

Yes

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants