CLIO API - 内部服务器错误 - 创建通信

CLIO API - Internal Server Error - Create Communication

我正在尝试将我的旧 v2 应用程序更新到 v4。我目前 运行 遇到一个问题,当我尝试使用实现 RestSharp 的 C# 创建通信时收到 "Internal Server Error" 消息。我的架构如下:

public class CommunicationList
{
    public List<MakeCommunication> data { get; set; }
}

public class MakeCommunication
{
    public string body { get; set; }
    public DateTime date { get; set; }
    public NestedMatter matter { get; set; }
    public string subject { get; set; }
    public string type { get; set; }

}

public class NestedMatter
{
    public int id { get; set; }
}

我正在用适当的数据填充对象。我对 RestSharp POST 的设置如下:

var request = new RestRequest("api/v4/communications.json", Method.POST);

        request.AddHeader("Authorization", "Bearer " + ConfigIt.readConfiguration("token"));
        request.AddParameter("fields", "body, date, matter{id}, subject, type");

我在不使用 AddJsonBody 方法的情况下序列化对象,因为我的研究使我相信 AddJsonBody 方法产生了格式错误 json 所以我使用以下代码序列化对象:

request.RequestFormat = DataFormat.Json;

request.AddBody(commWrapper);

comWrapper 是下面的 CommunicationList 类型的对象。

得到一个一般的内部服务器错误并没有给我任何调试这个东西的方向。有人见过类似的问题吗?有什么建议吗?

感谢您提供的任何帮助,此时我的眼睛都快要交叉了。

更新 - 12 月 15 日星期六


我对此做了更多的挖掘。使用 Fiddler 我能够验证这是发送到服务器的内容:

POST https://app.goclio.com/api/v4/communications.json HTTP/1.1
Authorization: Bearer ******************************
Accept: application/json, text/json, text/x-json, text/javascript, 
application/xml, text/xml
User-Agent: RestSharp/106.5.4.0
Content-Type: application/json
Host: app.goclio.com
Content-Length: 151
Accept-Encoding: gzip, deflate
Connection: Keep-Alive

{"data":[{"body":"test email for debug","date":"2018-12-15T14:23:23Z","matter:{"id":1035117666},"subject":"test","type":"EmailCommunication"}]}

我回到 https://app.clio.com/api/v4/documentation#operation/Communication#create 的 api 文档,仔细检查我是否发送了正确的请求。我相信它看起来是正确的,但显然我遗漏了一些东西。

这是我从服务器返回的响应。

HTTP/1.1 500 Internal Server Error
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Status: 500 Internal Server Error
X-RateLimit-Limit: 600
X-RateLimit-Reset: 1544883900
X-RateLimit-Remaining: 599
X-Request-Id: 41199f9a-f569-4688-97a7-04b309cf85ed
X-Frame-Options: SAMEORIGIN
Cache-Control: private, no-cache, no-store, must-revalidate
X-XSS-Protection: 1; mode=block
X-API-VERSION: 4.0.5
X-Content-Type-Options: nosniff
Date: Sat, 15 Dec 2018 14:24:09 GMT
Server: nginx
Content-Length: 75

{"error":{"type":"InternalServiceError","message":"Something went wrong."}}

我希望有人以前遇到过这个问题。非常感谢任何帮助。

看起来您在请求负载中为 data 发送的值是一个数组,而不是一个对象。在您链接的文档页面的边栏中有一个正确数据格式的示例。

您提供的负载似乎也包含无效的 json。 matter.

后缺少双引号

因此,如果您将有效负载更改为如下所示,它应该可以工作(为了便于阅读而扩展):

{
    "data":{
        "body":"test email for debug",
        "date":"2018-12-15T14:23:23Z",
        "matter":{"id":1035117666},
        "subject":"test",
        "type":"EmailCommunication"
    }
}