【问题标题】:Instana REST API, 405 error - how to fix?Instana REST API,405 错误 - 如何修复?
【发布时间】:2019-10-23 07:48:26
【问题描述】:

尝试通过 Instana REST API 获取接收信息。看起来像这样:

https://[URL]/api/application-monitoring/metrics/applications?'Content-Type: application/json' -d '{"timeFrame": {"windowSize": [SIZE], "to": [SIZE]}, "metrics": [{"metric": "calls", "aggregation": "SUM"}, {"metric": "errors", "aggregation": "MEAN"}, {"metric": "latency", "aggregation": "MEAN"}, {"metric": "latency", "aggregation": "MIN"}, {"metric": "latency", "aggregation": "MAX"}], "nameFilter":"[NAME]"}'

找回那个错误:

{
  "code": 405,
  "message": "HTTP 405 Method Not Allowed"
}

匹配的 Curl 脚本(我不能使用)看起来像这样并且可以工作:

curl -H 'Authorization: apiToken <APITOKEN>' -H 'Content-Type: application/json' -d '{"timeFrame": {"windowSize": [SIZE], "to": [SIZE]}, "metrics": [{"metric": "calls", "aggregation": "SUM"}, {"metric": "errors", "aggregation": "MEAN"}, {"metric": "latency", "aggregation": "MEAN"}, {"metric": "latency", "aggregation": "MIN"}, {"metric": "latency", "aggregation": "MAX"}], "nameFilter":[NAME]}' [URL]

有什么想法吗?

【问题讨论】:

    标签: rest instana


    【解决方案1】:

    该端点需要 POST,看来您正在使用 GET。因此方法不允许。

    【讨论】:

    • 我认为在将某些内容写入字段或任何内容时应该使用“POST”?
    • 文档明确说明 POST instana.github.io/openapi/#operation/getApplicationMetrics 这样想,你 POST 一个查询对象来得到你想要的结果。如果它是通过 GET 完成的,它将需要很多查询参数并且有点混乱。
    猜你喜欢
    • 2017-07-17
    • 1970-01-01
    • 2021-03-23
    • 2020-09-13
    • 2016-01-10
    • 2019-10-30
    • 1970-01-01
    • 1970-01-01
    • 2013-10-09
    相关资源
    最近更新 更多