【问题标题】:TFS REST API System.IterationPath returns errorTFS REST API System.IterationPath 返回错误
【发布时间】:2020-11-05 21:43:09
【问题描述】:

我正在使用 python 请求库将迭代路径传递给 REST API 查询中的字段。

>>> payload = {"name": "Audit Work Items","wiql": ("SELECT [System.Id],[System.WorkItemType],[System.Title],[System.AssignedTo],[System.State],[System.Tags],[System.IterationPath] FROM workitems WHERE [System.WorkItemType] = 'User Story' OR [System.WorkItemType] = 'Bug' AND [System.IterationPath] = '\2CES\Backlog\2020\20.1\20.1.5' ORDER BY [System.Id]")}
>>> response  = requests.post(organization_url, auth=HTTPBasicAuth(username, password), verify=False, json=payload)
>>> response.text
'{"$id":"1","innerException":null,"message":"TF51011: The specified iteration path does not exist. The error is caused by «\'\\u0002CES\\\\Backlog\x820\\u0010.1\\u0010.1.5\'».","typeName":"Microsoft.TeamFoundation.WorkItemTracking.Client.Wiql.SyntaxException, Microsoft.TeamFoundation.WorkItemTracking.Client.QueryLanguage","typeKey":"SyntaxException","errorCode":0,"eventId":0}'
>>>

我无法理解 REST API 返回的 innerException 以及为什么路径会在错误消息中显示一些二进制字符?

谁能帮我解决这个问题,提前谢谢。

【问题讨论】:

  • 您是否尝试转义反斜杠字符?

标签: python-3.x tfs azure-devops python-requests azure-devops-rest-api


【解决方案1】:

反斜杠需要转义。 \2CES 被解释为 Unicode 字符。试试\\2CES

【讨论】:

  • 解决方案奏效了。我为一个工作项获取了一个 ID,并通过来自 python 解释器的请求 GET 调用执行它,该解释器将结果集作为字典返回。我发现 System.IterationPath 在响应输出中被反斜杠转义了。
猜你喜欢
  • 1970-01-01
  • 2020-12-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-21
  • 2013-08-30
  • 2015-02-19
相关资源
最近更新 更多