I'm experimenting with a simple notebook in my AGOL account, following this post How to download feature layer(s) to local machine using notebook as a template.
Here is the code. Each block is a notebook cell:
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS
gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'home'</SPAN><SPAN class="punctuation token">)</SPAN>
item_id <SPAN class="operator token">=</SPAN> <SPAN class="string token">'4f9d1d1301864f8cabef08cbae7b2d3c'</SPAN>
item <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>get<SPAN class="punctuation token">(</SPAN>item_id<SPAN class="punctuation token">)</SPAN>
item_gdb <SPAN class="operator token">=</SPAN> item<SPAN class="punctuation token">.</SPAN>export<SPAN class="punctuation token">(</SPAN>item<SPAN class="punctuation token">.</SPAN>title <SPAN class="operator token">+</SPAN> <SPAN class="string token">'_test'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'File Geodatabase'</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
It errors out at line 7 with:
Exception<SPAN class="punctuation token">:</SPAN> You do <SPAN class="operator token">not</SPAN> have permissions to access this resource <SPAN class="operator token">or</SPAN> perform this operation<SPAN class="punctuation token">.</SPAN>
<SPAN class="punctuation token">(</SPAN>Error Code<SPAN class="punctuation token">:</SPAN> <SPAN class="number token">403</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN></SPAN>
What is odd about this is I can manually export the item from the item's details page without a problem, and the exported shapefile or gdb shows up in my root contents directory. I must be missing a simple step, but I don't know what it is.