Im trying to unregister a replica using REST API...
I can get a list of replicaID's but cant figure out how to construct the python to do the unregister..
for r in replica_list:
replicaIDValue = (r['replicaID'])
print(replicaIDValue)
portal_item = gis.content.get('8faacd82xxxxxxxxxac03410')
ports_layer = portal_item.layers[0]
#removeReplica = ports_layer.UnregisterReplica(replicaID = replicaIDValue)
removeReplica = portal_item.unRegisterReplica(replicaID = replicaIDValue)
I tried to user Ports_item which is the ID of the Service
Error:
removeReplica = portal_item.unRegisterReplica(replicaID = replicaIDValue)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py", line 10400, in __getattr__
"'%s' object has no attribute '%s'" % (type(self).__name__, name)
AttributeError: 'Item' object has no attribute 'unRegisterReplica'
and portal_item which is the specific feature TABLE in the service
Error
removeReplica = ports_layer.unRegisterReplica(replicaID = replicaIDValue)
AttributeError: 'FeatureLayer' object has no attribute 'unRegisterReplica'
Solved! Go to Solution.
Got it with this...
grove_layer = arcgis.gis.Item(gis, itemid="8faacxxxxxxxxxxx03410")
grove_layer_flc = arcgis.features.FeatureLayerCollection(grove_layer.url, gis)
replica_list = grove_layer_flc.replicas.get_list()
for r in replica_list:
replica = grove_layer_flc.replicas.get(r['replicaID'])
replica_id = replica["replicaID"]
print('Unregistering ' + replica_id)
grove_layer_flc.replicas.unregister(replica_id)
It seems like you're mixing up the REST API with the ArcGIS API for Python based on the mixed usage in the sample code.
What you are trying to do is documented here: Sync overview | ArcGIS API for Python
You have to start with a FeatureLayerCollection object. From there, you get the list of replicas using get_list() and use the results to later run unregister.
Or do I do something like a POST?
import http.client
connection = http.client.HTTPSConnection("www.journaldev.com")
connection.request("GET", "/")
response = connection.getresponse()
print("Status: {} and reason: {}".format(response.status, response.reason))
connection.close()
Got it with this...
grove_layer = arcgis.gis.Item(gis, itemid="8faacxxxxxxxxxxx03410")
grove_layer_flc = arcgis.features.FeatureLayerCollection(grove_layer.url, gis)
replica_list = grove_layer_flc.replicas.get_list()
for r in replica_list:
replica = grove_layer_flc.replicas.get(r['replicaID'])
replica_id = replica["replicaID"]
print('Unregistering ' + replica_id)
grove_layer_flc.replicas.unregister(replica_id)