无法在Clockify Api中使用“生成摘要报告”

时间:2018-11-17 01:45:08

标签: api clockify

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

   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
}

我不知道自己在做什么错,因此我们将不胜感激。

2 个答案:

答案 0 :(得分: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"
}

这对我有用,但是现在我收到“没有枚举常量com.clockify.domain.model.DashboardSelection.false”错误(代码3002),但我一直无法弄清楚。我使用的JSON昨天可以使用,但今天却无法使用...所以不确定发生了什么。

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

答案 1 :(得分: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 
}