Select to view content in your preferred language

Getting error while searching for portal users in PortalPy

3018
11
Jump to solution
09-04-2016 05:50 PM
GregStevenson
Regular Contributor

I am using PortalPy to search for and return users. I am getting the following error:

'NoneType' object has no attribute 'get'

I get the error whether I use 'search_users' or 'get_org_users'

The error only occurs when I attempt to return all users. If I search for a specific user or set of users they return fine. My code is:

portal = portalpy.Portal(portalUrl, portalAdminUser, portalAdminPassword)
users = portal.search_users('')

print(users)

Any thought as to what the cause is? There are no obvious problems with our portal users that would make them None objects. The same code worked previously.

Also possibly related is this new message when the script is run "No handlers could be found for logger "portalpy""

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
GregStevenson
Regular Contributor

I have embarrassingly solved my own problem. The problem was that the portal password was incorrect. This doesn't explain the error messages though, nor does it explain how I was able to access some of the portal users details despite having an invalid login.

Thanks for your help to those who replied.

View solution in original post

11 Replies
DanPatterson_Retired
MVP Emeritus

in python that means None was returned 

arguments but 1 was given
>>> a = None
>>> type(a)
<class 'NoneType'>

any function the 'gets' something or is designed just to run, required parameters or no parameters.

You specified portal.search_users('') .... have you tried portal.search_users()  ... ie empty braces to see if the defaults will be used if nothing is specified?  Or perhaps it requires some other wildcard.  Your request uses double single-quotes as the default parameter, something that I doubt it requires.

0 Kudos
GregStevenson
Regular Contributor

Hi Dan, I think portalpy uses 'get' when accessing the users within portal. It is failing during its own search. But if I place a specific search funtion it works (but only returns a sub-set of the users).  portal.search_users('') is used as a query term is required for search_users and the wildcards '*' and '?' do not work. portal.search_users() is invalid as there is no query.

0 Kudos
DanPatterson_Retired
MVP Emeritus

Ok ... just checking, I am suprised that there is no 'all' or 'any', like '*' use in arcpy

0 Kudos
GregStevenson
Regular Contributor

The documentation around what to place as the query is very poor. Although I don't think this is the problem. I have an identical script pointing to a different portal and it works fine.

0 Kudos
PaulDavidson1
Frequent Contributor

Given that this works on other Portals, it seems the issue is more with the Portal than the query?

But just in case,

maybe this will help (from: https://github.com/Esri/portalpy/blob/master/portalpy.py) :

Def search_users(self, q, sort_field='username', sort_order='asc', max_users=1000, add_org=True):

""" Searches portal users.

This gives you a list of users and some basic information

about those users. To get more detailed information (such as role), you

may need to call get_user on each user.

.. note::

A few things that will be helpful to know.

1. The query syntax has quite a few features that can't

be adequately described here. The query syntax is

available in ArcGIS help. A short version of that URL

is http://bitly.com/1fJ8q31.

2. Most of the time when searching groups you want to

search within your organization in ArcGIS Online

or within your Portal. As a convenience, the method

automatically appends your organization id to the query by

default. If you don't want the API to append to your query

set add_org to false. If you use this feature with an

OR clause such as field=x or field=y you should put this

into parenthesis when using add_org.

================ ========================================================

*Argument* *Description*

0 Kudos
GregStevenson
Regular Contributor

Yes I'm thinking that the issue is with the portal. But there are no problems anywhere else with the users (searching for specific users works fine). Previously ESRI has added users to the portal (esri_nav for example), i'm wondering if they've done something similar again that portalpy can't handle.

0 Kudos
GregStevenson
Regular Contributor

I have embarrassingly solved my own problem. The problem was that the portal password was incorrect. This doesn't explain the error messages though, nor does it explain how I was able to access some of the portal users details despite having an invalid login.

Thanks for your help to those who replied.

PaulDavidson1
Frequent Contributor

Thanks for posting that back Greg.

That is some “interesting” stuff.

Makes no sense that you could obtain any info without a proper password.

I’m assuming all the users you did get responses for were “named users?”

0 Kudos
GregStevenson
Regular Contributor

Yes, so i've just tested it again. With an incorrect password you can get responses for named users. But you cannot get responses for "all" named users (using '' as your query). But if you put in a search query such as 'greg' it will return all named users found.

0 Kudos