【问题标题】:Why my body (restsharp library) is incorrect?为什么我的身体(restsharp 库)不正确?
【发布时间】:2019-02-21 14:12:50
【问题描述】:

原始卷曲:

 -d 'client_id={client_id}'

我的 c# 代码:

Body body = new Body()
            {
                client_id = "20...8351"
            };
string json = JsonConvert.SerializeObject(body, Formatting.Indented);
request.RequestFormat = DataFormat.Json;
MessageBox.Show(json);
request.AddJsonBody(json);

作为回应,我收到了 client_id 与我的帐户不匹配的信息。我 100% 确定它是正确的,因为在 curl 测试仪中它运行良好。我认为这是json 变量格式的问题。你有什么建议吗?

【问题讨论】:

  • client_id 真的在你的身体里吗?不在网址中?
  • 是的,正如 api 文档所说。
  • @BartekMaćczak AddJsonBody 期望对象序列化,而不是序列化对象。

标签: c# restsharp


【解决方案1】:

我找到了解决方案: 针对 AddJsonBody 我使用了 AddParameter

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-20
    • 2018-07-31
    相关资源
    最近更新 更多