You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C# HttpClient发送POST请求至Leonardo端点提示"无效用户数据"求助

问题:调用飞行数据提交接口返回“invalid user data”错误

问题背景

我尝试向指定端点发送数据,请求失败并返回“invalid user data”。已确认用户名和密码正确,推测该提示表示数据缺失或格式无效。

使用在线请求工具发送请求时,服务器可正常接收用户数据,仅会因缺少文件数据报错(这是后续步骤的问题,当前卡在第一步)。但用C#控制台程序执行相同操作时,始终返回“invalid user data”。

C# 代码示例

await UploadFileAsync(@"d:\User\Downloads\test.igc", "MYPASS", "MYUSER");

async Task UploadFileAsync(string filePath, string user, string pass)
{
    HttpClient client = new HttpClient();

    string igcData = File.ReadAllText(filePath);

    var url = "http://www.paraglidingforum.com/modules/leonardo/flight_submit.php";

    var formData = new Dictionary<string, string>
        {
            { "user", user },
            { "pass", pass }
        };

    var content = new FormUrlEncodedContent(formData);

    var response = await client.PostAsync(url, content);
    response.EnsureSuccessStatusCode();
    var responseContent = await response.Content.ReadAsStringAsync();

    Console.WriteLine($"Response: {responseContent}"); // >>Invalid user data
}

可正常工作的HTML表单

我测试的HTML表单能让服务器接受用户数据,仅因缺少文件报错:

<html>   
<body>
    <form action="https://www.paraglidingforum.com/modules/leonardo/flight_submit.php" method="post" enctype="multipart/form-data">
        user: <input type="text" name="user" value="MYUSER">
        <br>
        pass: <input type="password" name="pass" value="MYPASS">
        <br>
        <input type="submit" value="Send">
    </form>
</body>
</html>

疑问

请问我的C#代码是否存在明显错误?

内容的提问来源于stack exchange,提问作者JoeTaicoon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 07:18:11