【问题标题】:How to get column from Azure DevOps using API in PowerBI?如何在 PowerBI 中使用 API 从 Azure DevOps 获取列?
【发布时间】:2023-02-03 13:11:30
【问题描述】:

我想通过调用 Power BI 中的 API 从 azure dev ops 获取一些数据。

我在 Power BI 脚本中尝试过这种方式: 获取数据 - 空白查询:

let
    Source = Json.Document(Web.Contents("https://dev.azure.com/xx/xx/_apis/wit/workitems/1695")),
    #"Converted to Table" = Record.ToTable(Source),
    #"Filtered Rows" = Table.SelectRows(#"Converted to Table", each true)
in
    #"Filtered Rows"

它会返回这个:

然后我选择 New Source - Web 并用这个 URL 填充 URL 部分:https://dev.azure.com/xx/xx/_apis/wit/workitems/1695

之后它将返回此表:

我的期望是,我需要获取所有 id 列,而不仅仅是 1695 的 1 个列,因为在我的 azure dev ops 中,我还有 100 个 idid等信息不一一查询就可以得到吗?

我真的很感谢任何帮助或建议。太感谢了

更新

我尝试通过列出工作项 ID 来使用 get-work 项,如下所示:

https://dev.azure.com/XX/XX/_apis/wit/workitems?ids=1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705

那么,如果我有超过 300 个 ID,我是否应该手动记下所有 ID? 任何人都可以提供一个想法吗?谢谢

【问题讨论】:

    标签: jquery json api powerbi


    【解决方案1】:

    根据API Doc

    你需要使用Work Items - Get Work Items Batch API

    URI 参数

    | Name         | In    | Required | Type   | Description                                                                                      |
    |--------------|-------|----------|--------|--------------------------------------------------------------------------------------------------|
    | organization | path  | True     | string | The name of the Azure DevOps organization.                                                       |
    | project      | path  |          | string | Project ID or project name                                                                       |
    | api-version  | query | True     | string | Version of the API to use. This should be set to '7.1-preview.1' to use this version of the api. |
    

    请求正文

    | Name        | Type                | Description                                                                                              |
    |-------------|---------------------|----------------------------------------------------------------------------------------------------------|
    | $expand     | WorkItemExpand      | The expand parameters for work item attributes. Possible options are { None Relations Fields Links All } |
    | asOf        | string              | AsOf UTC date time string                                                                                |
    | errorPolicy | WorkItemErrorPolicy | The flag to control error policy in a bulk get work items request. Possible options are {Fail Omit}.     |
    | fields      | string[]            | The requested fields                                                                                     |
    | ids         | integer[]           | The requested work item ids                                                                              |
    

    回应

    | Name   | Type       | Description          |
    |--------|------------|----------------------|
    | 200 OK | WorkItem[] | successful operation |
    

    笔记:首次 URL 命中将为您提供 200 条记录。但接下来你必须明确提供 ids 以逗号分隔

    因此,如果您有任何进一步的疑问,则必须通过创建帐户联系他们的支持。

    【讨论】:

      猜你喜欢
      • 2020-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-20
      • 1970-01-01
      • 1970-01-01
      • 2022-09-23
      • 1970-01-01
      相关资源
      最近更新 更多