Error record channel

Good morning,

I need to record the call via a channel so I only capture the customer’s voice. I’m trying to do so through this service, but I’m getting this error:

[May 14 12:45:37] ERROR[6120][C-0000000a]: res_stasis_recording.c:306 record_file: Cannot record channel while in bridge

LOGS:

May 14 12:45:40 VICIDIAL-PRU2 python[4269]: :speaking_head: Channel 1747244718.33 has started broadcasting.
May 14 12:45:40 VICIDIAL-PRU2 python[4269]: :studio_microphone: Recording channel 1747244718.33 - Status: 201 - Text: {
May 14 12:45:40 VICIDIAL-PRU2 python[4269]: “name”: “recording-1747244718.33”,
May 14 12:45:40 VICIDIAL-PRU2 python[4269]: “format”: “wav”,
May 14 12:45:40 VICIDIAL-PRU2 python[4269]: “state”: “queued”,
May 14 12:45:40 VICIDIAL-PRU2 python[4269]: “target_uri”: “channel:1747244718.33”
May 14 12:45:40 VICIDIAL-PRU2 python[4269]: }
May 14 12:45:40 VICIDIAL-PRU2 python[4269]: :no_mobile_phones: ARI event received: RecordingFailed
May 14 12:45:40 VICIDIAL-PRU2 python[4269]: :no_mobile_phones: ARI event received: ChannelTalkingFinished

COD:

def record_audio(channel_id):
url = f"{ARI_BASE_URL}/channels/{channel_id}/record"
params = {
“name”: f"grabacion-{channel_id}“,
“format”: “wav”,
“maxDurationSeconds”: 30,
“maxSilenceSeconds”: 4,
“beep”: False,
“mix”: True
}
try:
res = requests.post(url, params=params, auth=(ARI_USER, ARI_PASS))
res.raise_for_status()
log(f":studio_microphone: record Channel {channel_id} - status: {res.status_code} - text: {res.text}” )
except Exception as e:
log(f":cross_mark: Error record Channel {channel_id}: {e}")

You can’t record a channel while it’s in a bridge like that. You would need to create a Snoop channel, and then record the Snoop channel. This is the equivalent of doing MixMonitor in the dialplan.