代码之家  ›  专栏  ›  技术社区  ›  Alex Kwitny

使用VSTS Rest API,如何更新降价小部件?

  •  3
  • Alex Kwitny  · 技术社区  · 6 年前

    我想用 this REST API 更新VSTS中仪表板上的“降价”小部件。

    使用下面的 JSON 尸体,根据样本,我得到 Value cannot be null (见下文)?

    错误

    调用RestMethod:{“$id”:“1”,“innerException”:null,“message”:“Value” 不能为空。\r\n参数名称: 小部件“,”类型名称“:”系统。ArgumentNullException,mscorlib,“typeKey”:“ArgumentNullException”,“errorCode”:0,“eventId”:0}位于 C: \Users\alex\OneDrive\Documents\Scripts\VSTSPowershell\VSTSAuthenticateAndInvoke。ps1:36 字符:23+$结果=调用RestMethod-Uri$Uri-Method$Method -ContentType…+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +CategoryInfo:InvalidOperation:(System.Net.HttpWebRequest:HttpWebRequest)[调用RestMethod], WebException+FullyQualifiedErrorId: WebCmdletWebResponseException,微软。动力地狱。命令。InvokeRestMethodCommand

    JSON

    {
        "id": "3b52e9ed-576e-4985-82ae-8e80b22a4b4d",
        "eTag": "1",
        "name": "Markdown",
        "size": {"rowSpan":2; "columnSpan":2},
        "settings": "# AAAAK Markdown\nAdd content using the markdown widget.\n- **Bold**\n- *Italic*\n- [Links]()",
        "settingsVersion": "@{major=1; minor=0; patch=0}",
        "dashboard": {
            "eTag": "35"
          },
        "contributionId": "ms.vss-dashboards-web.Microsoft.VisualStudioOnline.Dashboards.MarkdownWidget"
    }
    

    小提琴手 Request / Response

    enter image description here

    我的目标就是找到&用新的显示内容更新降价小部件。这是一个新创建的小部件 eTag=1 ,我用Get Dashboard和 WidgetId ,以及 eTag=35 这就是仪表板。

    1 回复  |  直到 5 年前
        1
  •  4
  •   starian chen-MSFT    6 年前

    更改此行:

    "size": {"rowSpan":2; "columnSpan":2},
    

    "size": {"rowSpan":2, "columnSpan":2},