AttributeError: 'NoneType'

4338
6
04-12-2018 01:11 PM
AnooshehTarassoly
New Contributor III

I am trying to add a feature layer to a Web Map, and when running the ".add_layer()" method I am getting an error. The error is an AttributeError: 'NoneType' object has no attribute 'append'. Eventually, I would like to be able to run a loop and add the layer to a selection of web maps.

The two photos below show the Jupyter notebook of the steps I took. On a couple occasions, I ran the ".update()" method after the error with the .add_layer and the feature layer was still applied to the map, but this didn't always work. 

Any help would be greatly appreciated!

Jupyter Notebook screenshot part 1/2

0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus

NoneType means that 'None' was returned by a step.  But then you say that 'update' was used and it worked?  If that is the case, then whatever you did to remove the lack of something being returned is good

0 Kudos
AnooshehTarassoly
New Contributor III

Hi Dan, 

Thanks for the response! When I try the '.update()' method I get the same issue with the NoneType object. When I called the 'wmap' again to see why it was coming up as a NoneType, a popup dialog box asking me to log in with my credentials appeared (I have attached a photo below). I am wondering if this is why I am getting the NoneType error? 

Additionally, I noticed that when I pass '.update(item_description={})' (without signing in) the method returns True and the layer I wanted to add was successfully added. When I tried looping through multiple maps to add the layer to each map, while passing 'item_description{}' in the update method, the maps didn't update and I received the NoneType error again. If there is a way to stay signed in while calling the '.add_layer' and '.update' methods I believe this will solve my problem

0 Kudos
DanPatterson_Retired
MVP Emeritus

Sorry, Anoosheh, I don't do web stuff, but perhaps

KGerrow-esristaff

can put you in touch with the people that deal with AGOL and associated platforms.

KellyGerrow
Esri Frequent Contributor

Hi Anoosheh,

I'm not to sure on this one, but it appears that there is an issue with how the layer authentication is working.

If you input your username and password, are you able to run the tool?

If the layer is shared with everyone, Are you able to run the tool?

ArcGIS API for Python

ArcGIS Online

Also feel free to contact technical support to research this specific issue further.

-Kelly

0 Kudos
AnooshehTarassoly
New Contributor III

Hi Kelly, 

The tool seems to work seems to work whether I input my username and password or not. The layer should be shared with everyone. I will contact technical support for further assistance. 

Thanks for your help!

0 Kudos
BlakeTerhune
MVP Regular Contributor

I'm running into the same thing. I'm trying to export an item from an Open Data site so it doesn't need a user name. However, it errors on item.export(), yielding AttributeError: 'NoneType' object has no attribute 'username'

traceback is from "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 11928, in export
data_path = "content/users/%s/export" % self._gis.users.me.username

It seems export requires a username? What should I do?

0 Kudos