0

背景

问题

  • $filter 适用于大多数属性,但失败IDictionary<string,string>
  • 这就是我正在尝试的https://management.azure.com/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Automation/automationAccounts/XXX/jobs?$filter=properties/parameters/any(keyValue: keyValue/owner eq 'Adam@test.com')&api-version=2015-10-31
  • 请求失败并出现错误{ "code": "BadRequest", "message": "Could not find a property named 'owner' on type 'System.Collections.Generic.KeyValuePair_2OfString_String'." }

问题

  • 是否可以过滤我正在尝试的内容?
  • 如果是,那么我做错了什么?

我要对其应用过滤器的 JSON 响应

"value": [
        {
            "id": "/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Automation/automationAccounts/XXX/jobs/XXX",
            "properties": {
                "jobId": "XXX",
                "runbook": {
                    "name": "HelloWorldRunbook"
                },
                "schedule": null,
                "provisioningState": "Succeeded",
                "status": "Completed",
                "creationTime": "2018-06-17T05:44:12.197+00:00",
                "startTime": "2018-06-17T05:44:21.227+00:00",
                "lastModifiedTime": "2018-06-17T05:44:43.43+00:00",
                "endTime": "2018-06-17T05:44:43.43+00:00",
                "jobScheduleId": "7fc134ac-d8bd-464e-b041-6e6b50f83f0c",
                "runOn": null,
                "parameters": {
                  "Owner": "Adam@test.com",
                  "mailBox": "test_mailbox@test.com"
             }
            }
 ............removed for brevity

4

1 回答 1

0

当我尝试运行List Job By Automation Account Rest APIparameters时,响应正文中没有返回任何属性。

如果是,那么我做错了什么?

  ...
  "parameters": {
                  "Owner": "Adam@test.com",
                  "mailBox": "test_mailbox@test.com"
             }
   ...

但是根据您提到的响应 json 格式,参数属性是一个对象而不是字典,因此$filter=properties/parameters/Owner eq 'Adam@test.com'如果您确保参数存在,您可以使用它来执行此操作。

 Get https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Automation/automationAccounts/{automationAccountName}/jobs?api-version=2015-10-31&$filter=properties/parameters/Owner eq 'Adam@test.com'
于 2018-06-18T08:07:08.680 回答