How to get the mode when storing a new instance (OnStoredInstance)

Hello everyone.
Question:
When I try to use the orthanc hook, every time an image is stored, I haven’t been able to get its modality, only its instanceId. Both methods return “none,” so the hook triggers each image, and I only need to do it depending on the modality.
I’m trying with Python.
Image: jodogne/orthanc-python:latest
I’ve tried using the “dicom” object received in the function, but to no avail.

--------------------- CODE ----------------------------
import orthanc
import json
import urllib.request

def OnStoredInstance(dicom, instanceId):
print(“[INFO] Nueva instancia almacenada:”, instanceId)

try:
    headers = { 'Content-Type': 'application/json' }
    instance_data = json.loads(dicom.GetInstanceSimplifiedJson())
    modality = instance_data.get("MainDicomTags", {}).get("Modality", None)
    payload = {
        "InstanceID": instanceId,
        "Modality": modality
    }
    json_payload = json.dumps(payload).encode('utf-8')

    url = 'http://192.168.10.107:8020/hook'
    req = urllib.request.Request(url, data=json_payload, headers=headers)

    with urllib.request.urlopen(req, timeout=5) as response:
        print("[INFO] Notificacion enviada, codigo:", response.getcode())

except Exception as e:
    print("[ERROR] Fallo al enviar la notificacion:", str(e).encode('ascii', 'ignore').decode())

orthanc.RegisterOnStoredInstanceCallback(OnStoredInstance)

Regards!