GetFileBlobs - Query File Content

Updated at:

Retrieves the content of a specified file in a repository.

Applicable editions

Central edition, Region edition

Service Endpoints and Authorization Information

  • Get service endpoint: Replace {domain} in the API request syntax with the service endpoint.
  • Get a personal access token.
  • Obtain the organizationId: Required only for Central edition. You can obtain the organization ID from the Basic Information page in the Organization Management console.

Product

Resource

Required Permissions

Code Management

File

Read-only

Request Syntax

Central edition

GET https://{domain}/oapi/v1/codeup/organizations/{organizationId}/repositories/{repositoryId}/files/{rest:.*}

Region edition

GET https://{domain}/oapi/v1/codeup/repositories/{repositoryId}/files/{rest:.*}

Request Headers

Parameter

Type

Required

Description

Example Value

x-yunxiao-token

string

Yes

Personal access token.

pt-0fh3****0fbG_35af****0484

Request Parameters

Parameter

Type

Location

Required

Description

Example Value

organizationId

string

path

  • Yes: Central edition

  • No: Region edition

Organization ID.

60d54f3daccf2bbd6659f3ad

repositoryId

string

path

Yes

Repository ID, or the URL-encoded full path of the repository.

2813489 or 60de7a6852743a5162b5f957%2FDemoRepo

filePath

string

path

Yes

File path. URL-encode this parameter.

test.txt or src%2Fmain.java

ref

string

query

Yes

Reference name, typically a branch name but can also be a tag name or commit SHA.

master

Request Examples

Central edition

curl -X 'GET' \
  'https://{domain}/oapi/v1/codeup/organizations/60d54f3daccf2bbd6659f3ad/repositories/2813489 or 60de7a6852743a5162b5f957%2FDemoRepo/files/{rest:.*}?ref=master' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'

Region edition

curl -X 'GET' \
  'https://{domain}/oapi/v1/codeup/repositories/2813489 or 60de7a6852743a5162b5f957%2FDemoRepo/files/{rest:.*}?ref=master' \
  -H 'Content-Type: application/json' \
  -H 'x-yunxiao-token: pt-0fh3****0fbG_35af****0484'

Response Parameters

Parameter

Type

Description

Example Value

-

object

blobId

string

The Git object ID of the file.

b573bb50d56e8c19282593cbf5b081e211923a83

commitId

string

Commit ID.

6da8c14b5a9102998148b7ea35f96507d5304f74

content

string

File content.

dGVzdA==

encoding

string

Encoding rule. Valid values: text, base64. Default value: base64.

base64

fileName

string

File name.

main.java

filePath

string

File path.

src/test/main.java

lastCommitId

string

The commit ID of the last commit that modified the file.

6da8c14b5a9102998148b7ea35f96507d5304f74

ref

string

Typically a branch name, but can also be a tag name or commit SHA.

master

size

integer

File content size, in bytes.

4

Response Examples

{
    "blobId": "b573bb50d56e8c19282593cbf5b081e211923a83",
    "commitId": "6da8c14b5a9102998148b7ea35f96507d5304f74",
    "content": "dGVzdA==",
    "encoding": "base64",
    "fileName": "main.java",
    "filePath": "src/test/main.java",
    "lastCommitId": "6da8c14b5a9102998148b7ea35f96507d5304f74",
    "ref": "master",
    "size": 4
}

Error Codes

For API error codes, see Error Code Center.