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

时间:2018-05-16 15:09:20

标签: json rest azure-devops azure-pipelines-release-pipeline azure-devops-rest-api

我尝试使用this REST API来更新" Markdown" VSTS中仪表板上的小部件。

使用下面的JSON正文,根据示例,我得到Value cannot be null(见下文)?

错误

  

Invoke-RestMethod:{" $ id":" 1"," innerException":null," message":&#34 ;值   不能为空。\ r \ nParameter名称:   插件""的typeName":" System.ArgumentNullException,mscorlib程序"" typeKey":" ArgumentNullException""的errorCode& #34;:0," EVENTID":0}在   C:\用户\亚历克斯\ OneDrive \文件\脚本\ VSTSPowershell \ VSTSAuthenticateAndInvoke.ps1:36   char:23+ ... $ result = Invoke-RestMethod -Uri $ uri -Method $ method   -ContentType ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~       + CategoryInfo:InvalidOperation:(System.Net.HttpWebRequest:HttpWebRequest)[Invoke-RestMethod],   WebException + FullyQualifiedErrorId:   WebCmdletWebResponseException,Microsoft.PowerShell.Commands.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"
}

Fiddler Request / Response

enter image description here

我的目标只是找到&使用新的显示内容更新Markdown小部件。它是一个新创建的小部件,所以eTag=1,我使用获取信息中心和WidgetId验证,而eTag=35就是信息中心。

1 个答案:

答案 0 :(得分:2)

更改此行:

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

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