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.
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
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Caterina Curti
Just quickly seeing if you were able to submit a ticket?
I had a look in the BCLOUD and FRGE projects and couldn't see any related tickets.
Thanks, Josh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And finally, here you are: https://jira.atlassian.com/browse/BCLOUD-23289
(Sorry it took this long but please know that I've discussed this when you posted it with the team)
Caterina
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.