按ID查找报告:不支持请求方法“ GET”

时间:2018-11-02 21:46:26

标签: excel vba api get clockify

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

我收到此错误消息:

  

{“数据”:{“消息”:“不支持请求方法'GET'”,“代码”: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方法?

1 个答案:

答案 0 :(得分: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}不在工作空间中,因为可以将报告公开...但这只是一个猜测。