Unirest Java POST 请求对讲 API return 错误 500

Unirest Java POST request for Intercom API return error 500

我目前正尝试在 Intercom API using unirest 上针对 java 执行 POST 请求,它 returns 服务器错误 500 但是当我执行相同的请求时邮递员 returns 我想要的结果。

示例代码:

Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");
headers.put("Content-Type", "application/json");
headers.put("Authorization", "Bearer XXXXXXXXXXXXXXXXXXXXXXX");

HttpResponse response = Unirest
              .post("https://api.intercom.io/conversations/search")
              .headers(headers)
              .body(requestBody)
              .asObject(HashMap.class);

这是我的请求正文

private Map<String, Object> getQueryValues(String field, String operator, Object value) {
    Map<String, Object> map = new HashMap<>();
    map.put("field", field);
    map.put("operator", operator);
    map.put("value", value);

    return map;
}

private Map<String, Object> getRequestBody() {
    List<Map<String, Object>> value = new ArrayList<>();
    value.add(getQueryValues("updated_at", ">", 1590278400));
    value.add(getQueryValues("source.delivered_as", "=", "admin_initiated"));

    Map<String, Object> query = new HashMap<>();
    query.put("operator", "AND");
    query.put("value", value);

    Map<String, Object> requestBody = new HashMap<>();
    requestBody.put("query", query);

    return requestBody;
}

问题原来是我的 UNIX 日期长值,其中正确的值应该是纪元秒。所以我从 myDate.getTime() 改为 myDate.toInstant().getEpochSecond().