Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Downloading full repository content from resolver

josh- December 24, 2023

Hi there,

I'm attempting to download a repository's contents in a Forge resolver.

To accomplish this, I'm trying to call the the repository archive endpoint, as documented on this Bitbucket Cloud knowledge base page:

https://bitbucket.org/<workspace-name>/<repo>/get/<branch>.<zip|gz|bz2>

However when running the the following code:

const response = await api
.asApp()
.requestBitbucket(
routeFromAbsolute(
`https://bitbucket.org/${workspaceId}/${slug}/get/master.zip`
)
);

this error is thrown:

PROXY_ERR: Forge platform failed to process runtime HTTP request - 400 - INVALID_TARGET_URL
at handleProxyResponseErrors (webpack://bitbucket-repository-main-menu-page-ui-kit-2/node_modules/@forge/api/out/api/fetch.js:27:1)
at <anonymous> (webpack://bitbucket-repository-main-menu-page-ui-kit-2/node_modules/@forge/api/out/api/fetch.js:15:1)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
status: 400,
errorCode: 'INVALID_TARGET_URL'
}

Is it possible to use this endpoint to retrieve the repository contents as a zip file when using Forge?

Otherwise is there a recommended alternative endpoint that could be used? As noted here it's not possible to use the List Download Artifacts endpoint because only manually-uploaded files are returned there from the API, and not the "Download repository" item as listed in the UI.

1 answer

Suggest an answer

Log in or Sign up to answer
1 vote
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 26, 2023

Hi @josh- ,

Can I ask you to provide more details about what you are trying to achieve?

There might be some other alternatives and knowing the use case could help us to identify those.

We can confirm that the API from the Knowledge Base article is currently not available when using Forge and we can't think of an alternative endpoint, but maybe with some more details, we can think about some other options. 


For example, if you are trying to read the content of a file, you could be using what I described in the Reading a file from a repository in Bitbucket using the REST API article.

Let us know,
Caterina

josh- December 27, 2023

Thanks @Caterina Curti,

I'm attempting to duplicate a repository's files in a newly-created repository without commit history (eg. a new repository would be created with a single commit containing all files from the original repository).

Without access to the archive endpoint it seems my two options to retrieve the full repository contents is to either:

How do these sound to you and do you know of any other potential solutions?

Like Steffen Opel _Utoolity_ likes this
josh- January 26, 2024

Hey @Caterina Curti

Just quickly checking whether you saw my response above?

Thanks!

Like Caterina Curti likes this
Caterina Curti
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 30, 2024

Hey @josh- ,
Sorry, I was busy organizing and presenting at a few events and never got to reply here.

The use case is clear now and I will create a feature request about this. Most likely, this will take some time before it is made available.

I'm still travelling for the events, I'll create the ticket and share it here once I'm back.

Caterina

Like josh- likes this
josh- February 7, 2024

Thanks Caterina - that sounds great.

TAGS
AUG Leaders

Atlassian Community Events