I'm working a script to automate the updating of subnetworks against the default version and when run it keeps returning the following error message:
arcgisscripting.ExecuteError: ERROR 000228: Cannot open the dataset.
The utility network service was created using a user that has permissions to update the default version and if I run the code snippet from a ArcGIS Pro session it will run fine, even if I'm logged into the portal as a regular user. I have also tried changing the credentials by importing them from a server connection file with the correct user credentials but the script also fails.
import arcpy retval = arcpy.un.UpdateSubnetwork('https://my_server/server/rest/services/UN_UPDATE_IaaS_DB1/FeatureServer/0','Pipeline', 'System', 'SPECIFIC_SUBNETWORK', 'DS 01-0247', 'STOP_ON_FAILURE',include_barriers='INCLUDE_BARRIERS',traversability_scope='BOTH_JUNCTIONS_AND_EDGES')
Are you sure that the feature service is pointing to the Utility Network service? That rest endpoint makes it look like it is higher up in the service list than the UN typically is. My UN (published from the base asset package template looks like this: rest/services/NapervilleWater/Water_Distribution_Utility_Network_Naperville_1081/FeatureServer/921
This is likely the case. The UN "feature class" that you would input is not the 0 level of the REST address to my knowledge, it's buried deeper down in there. If you have an unadulerated asset package it should be 8, but you can always go check the REST address of your published data in the content menu to find it.
If the UN layer is at the top of your publishing map, then it will get layer 0.
Try adding https://pro.arcgis.com/en/pro-app/latest/arcpy/functions/signintoportal.htm to your script. When running from Pro, it automatically inherits the token.