使用VSTS Rest API,如何更新Markdown小部件? [英] Using VSTS Rest API, how do you Update a Markdown widget?

查看:117
本文介绍了使用VSTS Rest API,如何更新Markdown小部件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用此REST API 来更新VSTS仪表板上的"Markdown"小部件.

I'm trying to use this REST API to Update a "Markdown" widget on a dashboard in VSTS.

使用下面的JSON主体,按示例获取Value cannot be null(请参见下文)?

Using the below JSON body, per the sample, I'm getting Value cannot be null (see below)?

Invoke-RestMethod:{"$ id":"1","innerException":null,"message":"Value 不能为null.\ r \ n参数名称: widget," typeName:" System.ArgumentNullException,mscorlib," typeKey:" ArgumentNullException," errorCode:0," eventId:0} C:\ Users \ alex \ OneDrive \ Documents \ Scripts \ VSTSPowershell \ VSTSAuthenticateAndInvoke.ps1:36 char:23+ ... $ result =调用RestMethod -Uri $ uri -Method $ method -ContentType ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~ + CategoryInfo:InvalidOperation:(System.Net.HttpWebRequest:HttpWebRequest)[Invoke-RestMethod], WebException + FullyQualifiedErrorId: WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Invoke-RestMethod : {"$id":"1","innerException":null,"message":"Value cannot be null.\r\nParameter name: widget","typeName":"System.ArgumentNullException,mscorlib","typeKey":"ArgumentNullException","errorCode":0,"eventId":0}At C:\Users\alex\OneDrive\Documents\Scripts\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"
}

提琴手Request/Response

Fiddler Request/Response

我的目标仅仅是找到&使用新的显示内容更新Markdown小部件.这是一个新创建的小部件,所以eTag=1是我通过Get Dashboard和WidgetId进行验证的,而eTag=35是Dashboard.

My goal is simply to find & update a Markdown widget with new display content. It's a newly created widget, so eTag=1, which I verified with a Get Dashboard along with the WidgetId, and the eTag=35 is what the Dashboard is.

推荐答案

更改此行:

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

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

这篇关于使用VSTS Rest API,如何更新Markdown小部件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆