首页 > 解决方案 > Azure Devops Rest API - 使用 PAT 时创建拉取请求所有者问题

问题描述

我正在尝试使用 createdby 选项创建拉取请求,如下面的 JSON 通过 rest api;

{
  "createdBy": {"id": "b568ab19-05a8-6199-9bee-95f3b7b994c9"},
  "sourceRefName": "refs/heads/hotfixes/hotfix-test-2",
  "targetRefName": "refs/heads/master",
  "title": "Merge SourceBranch to master",
  "description": "This PR Created automatically via REST API, plese do not forget to complete this PR!! ",
        "reviewers": [
            {
                "id": "a048902e-aa3b-62ac-9407-baff1ba594fb",
                "isRequired": "true"
            }
        ]
    }

但是 API 方法无法在 createdBy 区域处理我的用户 ID。Api 似乎在此区域使用个人访问令牌所有者。因为我使用 api 创建的所有拉取请求都具有相同的令牌所有者。请注意,api 可以真实地在审阅者区域获取此用户 id。

有没有人知道这种行为的细节?

这里是关于创建拉取请求的 API 参考;

发布https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}/pullrequests?api-version=5.0

https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20requests/create?view=azure-devops-rest-5.0

标签: gitrestazure-devopsdevopsazure-devops-rest-api

解决方案


推荐阅读