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)
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
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.