I used the ArcGIS API for Python (code below) to add a table to a hosted feature service, as well as adding a relationship between the new table and an existing feature layer in the service. The new table is visible in the REST page for the Feature Service, but I neither see it in the item description page (Overview or Data tabs) nor can I add it to a map by constructed URL. Was there a step or parameter I missed in uploading it with Python?
bf_table = r"Path/BrownfieldsInventory"
fields_def = []
for f in arcpy.ListFields(bf_table):
field_dict = {}
field_dict['name'] = f.name
field_dict['type'] = "esriFieldType" + f.type
field_dict['alias'] = f.aliasName
field_dict['length'] = f.length
field_dict['nullable'] = f.isNullable
field_dict['editable'] = f.editable
fields_def.append(field_dict)
tbl_definition = {
"id": 12,
"type" : "Table",
"name" : "Brownfields",
"description": "Description",
"fields": fields_def,
"indexes": [
{
"name": "PK_IDX",
"fields": "OBJECTID",
"isAscending": True,
"isUnique": True,
"description": "clustered, unique, primary key"
}
],
"objectIdField": "OBJECTID",
"uniqueIdField": {
"name": "OBJECTID",
"isSystemMaintained": True
}
}
item = gis.content.get("existingFeatureServiceID")
flc = FeatureLayerCollection.fromitem(item=item)
status = flc.manager.add_to_definition(json_dict={"tables": [tbl_definition]})