代码之家  ›  专栏  ›  技术社区  ›  JDH

如何在powershell中编写这个json负载

  •  0
  • JDH  · 技术社区  · 6 年前

    我不知道如何组成本文中描述的请求主体。

    https://docs.microsoft.com/en-us/rest/api/vsts/git/pull%20request%20query/get?view=vsts-rest-4.1#gitpullrequestqueryinput

    无论我的有效负载中是否有查询,我都会不断出现此错误:

    调用RestMethod:{“$id”:“1”,“innerException:”null,“message:”无效的参数值。\r\n参数名称:queries”,“typeName:”Microsoft.TeamFoundation.SourceControl.WebServer.InvalidArgumentValueException, 微软团队基金会。资源控制。WebServer、“typeKey”:“InvalidArgumentValueException”、“errorCode”:0、“eventId”:0}

    我在尝试这样的事情:

    $body= @{
        queries=@(
            @{
                items=@(0,1,2)
                type="commit"
            }
        )
        results=@()
    } | ConvertTo-Json
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   JDH    6 年前

    我的json格式是正确的,但最后没有添加深度是我的失败。

    $body = @{
      queries=@(
        @{
            items = @("xxxx")
            type = "commit"
        }
      )
      results=@()
    } | ConvertTo-Json -Depth 5