【问题标题】:Posting JSON data to Team Foundation Server 2018将 JSON 数据发布到 Team Foundation Server 2018
【发布时间】:2019-02-07 10:19:51
【问题描述】:

我正在尝试使用带有 http-post 的 POSTMAN 使用 JSON 打开新的用户故事。在 header 中是 Content-Type: application/json-patch+json

文件看起来像:

{
  "id":33560,
  "rev":2,
  "fields":{
    "System.AreaPath":"EJ2TFS",
    "System.TeamProject":"EJ2TFS",
    "System.IterationPath":"EJ2TFS\\Iteration 1",
    "System.WorkItemType":"User Story",
    "System.State":"New",
    "System.Reason":"New",
    "System.AssignedTo":"User, User <firm\\user>",
    "System.Title":"Postman_POST",
    "Microsoft.VSTS.Common.Priority":2,
    "Microsoft.VSTS.Common.ValueArea":"Business",
    "System.History":"Comment"
  }
}

错误:

   {
    "$id": "1",
    "innerException": null,
    "message": "You must pass a valid patch document in the body of the request.",
    "typeName": "Microsoft.VisualStudio.Services.Common.VssPropertyValidationException, Microsoft.VisualStudio.Services.Common",
    "typeKey": "VssPropertyValidationException",
    "errorCode": 0,
    "eventId": 3000
}

【问题讨论】:

    标签: json api http-post postman


    【解决方案1】:

    如果您想创建一个工作项 (Rest Api Work Items - Create),请使用下面的 url 和正文:

    发布

    http(s)://your_server:port/tfs/DefaultCollection/EJ2TFS/_apis/wit/workitems/$user story?api-version=4.0

    身体

    [
      {
        "op": "add",
        "path": "/fields/System.Title",
        "from": null,
        "value": "Postman_POST"
      },
      {
        "op": "add",
        "path": "/fields/System.AssignedTo",
        "from": null,
        "value": "User, User <firm\\user>"
      },
      {
        "op": "add",
        "path": "/fields/System.IterationPath",
        "from": null,
        "value": "EJ2TFS\\Iteration 1"
      }    
    ]
    

    【讨论】:

      猜你喜欢
      • 2018-09-21
      • 1970-01-01
      • 2018-11-07
      • 1970-01-01
      • 1970-01-01
      • 2019-06-12
      • 1970-01-01
      • 1970-01-01
      • 2020-04-04
      相关资源
      最近更新 更多