Items - Get

获取单个项的项元数据和/或内容。 download 参数用于指示内容是应作为下载内容提供,还是应作为响应中的流发送。 不适用于始终作为下载返回的压缩内容。

GET https://dev.azure.com/{organization}/{project}/_apis/tfvc/items?path={path}&api-version=7.1-preview.1
GET https://dev.azure.com/{organization}/{project}/_apis/tfvc/items?path={path}&fileName={fileName}&download={download}&scopePath={scopePath}&recursionLevel={recursionLevel}&versionDescriptor.version={versionDescriptor.version}&versionDescriptor.versionOption={versionDescriptor.versionOption}&versionDescriptor.versionType={versionDescriptor.versionType}&includeContent={includeContent}&api-version=7.1-preview.1

URI 参数

名称 必需 类型 说明
organization
path True

string

Azure DevOps 组织的名称。

project
path

string

项目 ID 或项目名称

api-version
query True

string

要使用的 API 版本。 这应设置为“7.1-preview.1”才能使用此版本的 API。

path
query True

string

要返回的单个项的版本控制路径。

download
query

boolean

如果为 true,则创建可下载的附件。

fileName
query

string

返回的项的文件名。

includeContent
query

boolean

设置为 true 以在请求 json 时包括项内容。 默认值为 false。

recursionLevel
query

VersionControlRecursionType

无 (仅) 项,或 OneLevel (文件夹) 的内容。

scopePath
query

string

要返回多个项目的文件夹的版本控制路径。

versionDescriptor.version
query

string

版本对象。

versionDescriptor.versionOption
query

TfvcVersionOption

版本描述符。 默认值为 null。

versionDescriptor.versionType
query

TfvcVersionType

版本描述符。 默认值为 null。

响应

名称 类型 说明
200 OK

TfvcItem

成功的操作

Media Types: "text/plain", "application/octet-stream", "application/zip", "application/json"

安全性

oauth2

Type: oauth2
Flow: accessCode
Authorization URL: https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
Token URL: https://app.vssps.visualstudio.com/oauth2/token?client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer

Scopes

名称 说明
vso.code 授予读取有关提交、更改集、分支和其他版本控制项目的源代码和元数据的能力。 此外,还授予搜索代码的功能,并通过服务挂钩获取有关版本控制事件的通知。

示例

GET item metadata and/or content for a single item.

Sample Request

GET https://dev.azure.com/{organization}/_apis/tfvc/items?path=$/MyFirstProject/ExampleFolder/TestFile01.txt&api-version=7.1-preview.1

Sample Response

{
  "version": 10,
  "changeDate": "2019-05-29T18:00:23.457Z",
  "size": 4,
  "hashValue": "CY9rzUYh03PK3k6DJie09g==",
  "encoding": 65001,
  "path": "$/MyFirstProject/ExampleFolder/TestFile01.txt",
  "contentMetadata": {
    "encoding": 65001,
    "contentType": "text/plain",
    "fileName": "TestFile01.txt",
    "extension": ".txt",
    "vsLink": "vsweb://vs/?Product=Visual_Studio&Gen=2013&EncFormat=UTF8&tfslink=dnN0ZnM6Ly8vVmVyc2lvbkNvbnRyb2wvTGF1bmNoTGF0ZXN0VmVyc2lvbmVkSXRlbS8lMjQlMmZNeUZpcnN0UHJvamVjdCUyZkV4YW1wbGVGb2xkZXIlMmZUZXN0RmlsZTAxLnR4dD9wcm9qZWN0PTg3NDQ2MjJkLTdmMGUtNDZlZi04ZjViLWUxNzk2MjNhNGI1YyZ1cmw9aHR0cHMlM0ElMkYlMkZjb2RlZGV2Lm1zJTJGa2V2aW5tY3B6NDIwJTJG"
  },
  "url": "https://codedev.ms/fabrikam/_apis/tfvc/items/$/MyFirstProject/ExampleFolder/TestFile01.txt?versionType=Latest&versionOptions=None",
  "_links": {
    "self": {
      "href": "https://codedev.ms/fabrikam/_apis/tfvc/items/$/MyFirstProject/ExampleFolder/TestFile01.txt?versionType=Changeset&version=10"
    }
  }
}

定义

名称 说明
FileContentMetadata
ReferenceLinks

表示 REST 引用链接集合的类。

TfvcItem

项的元数据。

TfvcVersionOption

默认值为“None”。

TfvcVersionType

默认为“最新”。

VersionControlRecursionType

默认为 OneLevel。

FileContentMetadata

名称 类型 说明
contentType

string

encoding

integer

extension

string

fileName

string

isBinary

boolean

isImage

boolean

vsLink

string

表示 REST 引用链接集合的类。

名称 类型 说明
links

object

链接的只读视图。 由于引用链接是只读的,因此我们只想将其公开为只读。

TfvcItem

项的元数据。

名称 类型 说明
_links

ReferenceLinks

表示 REST 引用链接集合的类。

changeDate

string

项已更改日期/时间。

content

string

contentMetadata

FileContentMetadata

deletionId

integer

如果删除项,则大于 0。

encoding

integer

来自数据库的文件编码,-1 表示二进制。

hashValue

string

MD5 哈希作为 base 64 字符串,仅适用于文件。

isBranch

boolean

如此 如果项是分支。

isFolder

boolean

isPendingChange

boolean

如此 如果更改挂起。

isSymLink

boolean

path

string

size

integer

文件的大小(如果适用)。

url

string

version

integer

变更集版本 ID。

TfvcVersionOption

默认值为“None”。

名称 类型 说明
none

string

无。

previous

string

返回以前的版本。

useRename

string

仅可用于 versiontype MergeSource 和整数版本,使用 RenameSource 标识符而不是合并标识符。

TfvcVersionType

默认为“最新”。

名称 类型 说明
change

string

版本被视为更改。

changeset

string

版本被视为 ChangesetId。

date

string

版本被视为日期。

latest

string

如果定义了 Version,则将使用该版本的最新版本,如果未定义版本,将使用最新的 ChangesetId。

mergeSource

string

版本将被视为 MergeSource。

none

string

版本被视为 ChangesetId。

shelveset

string

版本被视为搁置集名称和所有者。

tip

string

版本将被视为提示,如果未定义最新版本,则将使用。

VersionControlRecursionType

默认为 OneLevel。

名称 类型 说明
full

string

返回指定的项和所有后代

none

string

仅返回指定的项。

oneLevel

string

返回指定的项及其直接子项。

oneLevelPlusNestedEmptyFolders

string

返回指定项及其直接子级,以及仅包含单个文件夹的嵌套子文件夹的递归链。