I can't apply the modifier programmatically via Python, but clicking the GUI button works.
Some answers on this site say bpy.ops
commands usually demand the current active object be proper.
>>> bpy.context.scene.objects.active
bpy.data.objects['Icosphere']
tells me my active object is proper.
But still, I get
>>> bpy.ops.object.modifier_apply(apply_as='DATA')
{'CANCELLED'}
Again, clicking the GUI button works without problems. How may I do it via script?