Select to view content in your preferred language

Exception: You do not have permissions to access this resource or perform this operation. (Error Code: 403)

1250
2
07-01-2023 08:14 AM
Labels (3)
IB3
by
Occasional Contributor

Hi, 

I am the administrator of an AGOL account, but when I run this script, I get a 403 error. How is it possible and any idea how I can solve this?

from arcgis.gis import GIS
from arcgis import features
from datetime import date
import pandas as pd
import os
import io
import requests
gis = GIS("Home")

 

# Specify the item ID of the map
map_item_id = "470e800329c9490fba5e43f9ba7faef1"

# Retrieve the map item
map_item = gis.content.get(map_item_id)

# Retrieve the layers from the map item
map_layers = map_item.get_data()['operationalLayers']

# Extract only the titles of the feature layers
layer_titles = [layer['title'] for layer in map_layers if layer['layerType'] == 'ArcGISFeatureLayer']

# Print the layer titles
print(layer_titles)

0 Kudos
2 Replies
David_McRitchie
Esri Contributor

Is the item set to private and owned by another user? If so then I would ask them to share this to the organisation or to a group and invite you to this.

Hope that helps,

David

 

Esri UK -Technical Support Analyst
0 Kudos
GabrielMarcus_C
New Contributor III

I received the same error today and fixed it with 2 modifications.
I was logged into a different portal within AGP. Changing that removed the error. 

Like in your example, I was using gis("home") which apparently uses the active portal set in AGP. 
Since then, I updated the script to explicitly specify the portal. 

0 Kudos