Items - Get

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

GET https://dev.azure.com/{organization}/{project}/_apis/tfvc/items?path={path}&api-version=7.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

URI 参数

名称 必需 类型 说明
organization
path True

string

Azure DevOps 组织的名称。

project
path

string

项目 ID 或项目名称

api-version
query True

string

要使用的 API 版本。 这应设置为“7.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

Version 对象。

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

类型: oauth2
流向: accessCode
授权 URL: https://app.vssps.visualstudio.com/oauth2/authorize&response_type=Assertion
令牌 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

作用域

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

示例

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

示例请求

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

示例响应

{
  "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 (int32)

extension

string

fileName

string

isBinary

boolean

isImage

boolean

vsLink

string

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

名称 类型 说明
links

object

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

TfvcItem

项的元数据。

名称 类型 说明
_links

ReferenceLinks

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

changeDate

string (date-time)

项已更改日期/时间。

content

string

contentMetadata

FileContentMetadata

deletionId

integer (int32)

如果项目被删除,则大于 0。

encoding

integer (int32)

从数据库进行文件编码,-1 表示二进制文件。

hashValue

string

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

isBranch

boolean

如此 如果项是分支。

isFolder

boolean

isPendingChange

boolean

如此 如果存在挂起的更改。

isSymLink

boolean

path

string

size

integer (int64)

文件大小(如果适用)。

url

string

version

integer (int32)

更改集版本 ID。

TfvcVersionOption

默认值为 None。

说明
none

没有。

previous

返回以前的版本。

useRename

只能与 versiontype MergeSource 和整数版本一起使用,使用 RenameSource 标识符而不是合并标识符。

TfvcVersionType

默认为“最新”。

说明
change

版本被视为更改。

changeset

版本被视为 ChangesetId。

date

版本被视为日期。

latest

如果版本被定义为将使用最新版本,则如果未定义任何版本,将使用最新的 ChangesetId。

mergeSource

版本将被视为 MergeSource。

none

版本被视为 ChangesetId。

shelveset

版本被视为“货架集”名称和所有者。

tip

如果未使用任何版本,则版本将被视为提示。

VersionControlRecursionType

默认为 OneLevel。

说明
full

返回指定项和所有后代

none

仅返回指定的项。

oneLevel

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

oneLevelPlusNestedEmptyFolders

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