0

我正在尝试使用 Excel 中的 VBA 从一份报告中获取数据。

我收到此错误消息:

{"data":{"message":"不支持请求方法 'GET'","code":3000}}

这是我的代码:

Dim strUrl As String
        strUrl = "https://api.clockify.me/api/workspaces/{workspaceId}/reports/{reportId}/"

Set hReq = CreateObject("MSXML2.XMLHTTP")
    With hReq
        .Open "GET", strUrl, False
        .SetRequestHeader "X-api-key", "{api-key}"
        .SetRequestHeader "content-type", "application/json"
        .Send
    End With

'wrap the response in a JSON root tag "data" to count returned objects
Dim response As String
    response = "{""data"":" & hReq.ResponseText & "}"
    Debug.Print response

为什么这里不允许使用 GET 方法?

4

1 回答 1

0

查看文档(https://clockify.github.io/clockify_api_docs/#tag-Report)...我没有看到“GET /workspaces/{workspaceId}/reports/{reportId}/”API 调用 -关闭是 GET /reports/{reportId} 或 PUT/DELETE /workspaces/{workspaceId}/reports/{reportId},这可以解释为什么你得到“GET not allowed”,因为你只能 PUT 或 DELETE /workspaces/{workspaceId}/reports/{reportId}/ 端点。我猜你想要“GET /reports/{reportId}”。试试看。

而且我猜这个 GET /reports/{reportId} 不在工作区下,因为报告可以公开......但这只是一个猜测。

于 2018-12-12T20:15:48.367 回答