无法调用Azure管理事件REST API

时间:2016-07-28 15:48:57

标签: api rest azure curl

我正在尝试使用此处的其余API:https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx来获取订阅中的azure事件。我非常仔细地按照说明操作,但我的GET请求返回400错误:

{"Code":"BadRequest","Message":"The $filter query parameter value is invalid."}

我的cURL请求如下所示。我已经编辑了任何私人信息

curl -X GET -H "Authorization: bearer XXX" -H "content-type: application/json" "https://management.azure.com/subscriptions/YYY/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04-01&$filter=eventTimestamp%20ge%20%272016-07-25T22:00:37Z%27%20and%20eventTimestamp%20le%20%272016-07-25T23:36:37Z%27%20and%20eventChannels%20eq%20%27Admin,%20Operation%27"

我尝试了过滤器参数的许多变体,但我认为这应该是正确的。每个空间都被%20替换,每个空间都被替换为被%27取代。

如果有人可以告诉我正确的查询应该是什么样的,我真的很感激!

谢谢!

1 个答案:

答案 0 :(得分:0)

请尝试将url上的双引号更改为单引号。修改后它在我身边工作正常。

如,

curl -X GET -H 'Authorization: bearer <token>' -H 'content-type: application/json' 'https://management.azure.com/subscriptions/XXX/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04-01&$filter=eventTimestamp%20ge%20%272016-07-25T22:00:37Z%27%20and%20eventTimestamp%20le%20%272016-07-25T23:36:37Z%27%20and%20eventChannels%20eq%20%27Admin,%20Operation%27'