From 2a87dd346e64fb07ef94cc82683160bc59bbe512 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 23 Feb 2026 21:21:48 -0800 Subject: [PATCH] fix: send empty JSON body to voice session endpoint (fixes 422) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FastAPI 的 create_session 端点声明了 Pydantic request body (CreateSessionRequest),虽然所有字段都有默认值,但 FastAPI 仍要求请求包含有效 JSON body(至少 {})。Flutter 端 dio.post 未传 data 参数导致 Content-Type 缺失,FastAPI 返回 422 Unprocessable Entity。修复:添加 data: {} 发送空 JSON 对象。 Co-Authored-By: Claude Opus 4.6 --- .../features/agent_call/presentation/pages/agent_call_page.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/it0_app/lib/features/agent_call/presentation/pages/agent_call_page.dart b/it0_app/lib/features/agent_call/presentation/pages/agent_call_page.dart index 4f40da5..804d55b 100644 --- a/it0_app/lib/features/agent_call/presentation/pages/agent_call_page.dart +++ b/it0_app/lib/features/agent_call/presentation/pages/agent_call_page.dart @@ -86,7 +86,7 @@ class _AgentCallPageState extends ConsumerState try { final dio = ref.read(dioClientProvider); final config = ref.read(appConfigProvider); - final response = await dio.post('${ApiEndpoints.voice}/sessions'); + final response = await dio.post('${ApiEndpoints.voice}/sessions', data: {}); final data = response.data as Map; _sessionId = data['session_id'] as String? ?? data['sessionId'] as String? ?? data['id'] as String?;