Thank you very much for your reply @Clubdebambos and for going as in-depth as you did!
To clarify, I have been attempting to set showLabels within the feature layer and not within the service. However, I have been using a slightly different technique than what you have done.
from arcgis import features, GIS
# Get the feature service item
item = agol.content.get("Feature Service ID")
# Convert to FeatureLayerCollection object
flc = features.FeatureLayerCollection.fromitem(item)
# Add/append layer definitions
flc.manager.add_to_definition({"layers": [layer_definitions]})
Each definition in layer_definitions is roughly as follows
{
"type": "Feature Layer",
"extent": {
"xmax": 180.0,
"ymin": -90.0,
"xmin": -180.0,
"ymax": 90.0,
"spatialReference": {
"wkid": 4326,
"latestWkid": 4326
}
},
"hasAttachments": false,
"name": <layer_name>,
"fields": [
{
"alias": <field_alias>,
"name": <field_name>,
"type": "esriFieldTypeString"
}
],
"drawingInfo": {
"renderer": {
"type": "simple",
"symbol": {
"type": "esriSMS",
"color": [
66,
135,
245,
255
],
"style": "esriSMSCircle",
"size": 10,
}
},
"scaleSymbols": false,
"labelingInfo": [
{
"labelExpressionInfo": {
"expression": "$feature[\"<name>\"]"
},
"labelPlacement": "esriServerPointLabelPlacementCenterRight",
"minScale": 0,
"maxScale": 0,
"symbol": {
"color": [
51,
51,
51,
255
],
"font": {
"decoration": "none",
"family": "Arial",
"size": 8,
"style": "normal",
"weight": "normal"
},
"haloColor": null,
"haloSize": null,
"horizontalAlignmen": "center",
"kerning": true,
"rightToLeft": false,
"type": "esriTS",
"verticalAlignment": "baseline",
"xoffset": 0,
"yoffset": 0
},
"useCodedValues": false
}
],
"transparency": 0
},
"showLabels": true,
"geometryType": "esriGeometryPoint"
}
Every other parameter works as expected, except for showLabels. I end up with a bunch of points that have no labels. If I go into the layer settings on the web map and click "Create Labels", then they show up with the information specified in labelingInfo.
I was going to try to use your method, but I am running into a slight issue. When I use get_data() on the item returned from the feature service, it is returning an empty dictionary. I don't know if that could indicate a larger issue with my creation of the feature service. Additionally, I can see in the returned item object that 'layers' is None despite the fact that I can see my created layers when viewing the map in the portal. Do either of these issues indicate a problem with my setup of the service and it's layers? If yes, could this be causing the labels to not render properly? Given that everything else is working as intended, I believe I set it up correctly, but perhaps I am mistaken.
Thanks again for your time!