fix: send empty JSON body to voice session endpoint (fixes 422)
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 <noreply@anthropic.com>
This commit is contained in:
parent
45c54acb87
commit
2a87dd346e
|
|
@ -86,7 +86,7 @@ class _AgentCallPageState extends ConsumerState<AgentCallPage>
|
|||
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<String, dynamic>;
|
||||
|
||||
_sessionId = data['session_id'] as String? ?? data['sessionId'] as String? ?? data['id'] as String?;
|
||||
|
|
|
|||
Loading…
Reference in New Issue