1

我一直在尝试使用 Clockify api 生成报告,并且一直在关注官方文档。首先我尝试使用自己的数据,但经过反复试验,我什至开始尝试默认数据。也没有运气。根据文档,这应该有效:

   curl -X POST -H 'X-Api-Key: {apikey}' -H 'content-type: application/json' -d '{
    "startDate": "2018-06-18T00:00:00.000Z",
    "endDate": "2018-06-24T23:59:59.999Z",
    "me": "false",
    "userGroupIds": "[]",
    "userIds": "[]",
    "projectIds": "[]",
    "clientIds": "[]",
    "taskIds": "[]",
    "tagIds": "[]",
    "billable": "BOTH",
    "includeTimeEntries": "true",
    "zoomLevel": "week",
    "description": "",
    "archived": "Active",
    "roundingOn": "false"
    }' -v -i 
 'https://api.clockify.me/api/workspaces/{workspace}/reports/summary/'

但事实并非如此。响应将是:

{
  "message": "Could not read document: Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token\n at [Source: java.io.PushbackInputStream@4a679880; line: 5, column: 19] (through reference chain: com.clockify.adapter.http.summaryReport.GetSummaryReportRequest[\"userGroupIds\"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token\n at [Source: java.io.PushbackInputStream@4a679880; line: 5, column: 19] (through reference chain: com.clockify.adapter.http.summaryReport.GetSummaryReportRequest[\"userGroupIds\"])",
  "code": 3002
}

我不知道我做错了什么,所以任何帮助将不胜感激。

4

2 回答 2

0

问题在于它们的默认数据 - 数组不应包含在“”中,因此正确的数据将是:

{
    "startDate": "2018-06-18T00:00:00.000Z",
    "endDate": "2018-06-24T23:59:59.999Z",
    "me": "false",
    "userGroupIds": [],
    "userIds": [],
    "projectIds": [],
    "clientIds": [],
    "taskIds": [],
    "tagIds": [],
    "billable": "BOTH",
    "includeTimeEntries": "true",
    "zoomLevel": "week",
    "description": "",
    "archived": "Active",
    "roundingOn": "false"
}

这对我有用,但现在我收到“No enum constant com.clockify.domain.model.DashboardSelection.false”错误(代码 3002),我无法弄清楚。我使用的 JSON 昨天还在工作,但今天不行……所以不确定发生了什么。

编辑:删除“我”字段,它可以防止我得到的错误。如果您只想要自己的条目,只需将您的用户 ID 放入 userIds 字段即可。

于 2018-12-12T17:02:53.570 回答
0

这对我有用:

data = {
    "startDate":f"{start}T00:00:00.000Z",
    "endDate": f"{end}T23:59:59.999Z",
    "me": "false",
    "userGroupIds": [],
    "userIds": [],
    "projectIds": [],
    "clientIds": [],
    "taskIds": [],
    "tagIds": [],
    "billable": "BOTH",
    "includeTimeEntries": True,
    "zoomLevel": "month",
    "description": "",
    "archived": "Active",
    "roundingOn": False 
}
于 2020-02-22T18:51:15.517 回答