Bitbucket Rest Api call using python resulting in 404 status code for archive - bitbucket-server

I am trying to use Bitbucket server rest api in python to get an archive of a certain commit. I am following the rest api documentation as below.
/REST/API/1.0/PROJECTS/{PROJECTKEY}/REPOS/{REPOSITORYSLUG}/ARCHIVE?AT&FILENAME&FORMAT&PATH&PREFIX
My python code to implement above api is as below.
url = 'https://bitbucket.xxxx.com/rest/api/1.0/projects/CMPOC/repos/hello-world/archive?at=b34bb40f9e5&format=zip'
headers = {'Content-Type': 'application/json'}
r = requests.get(url, auth=('username', 'password'), headers=headers)
print(r.status_code)
404
I am getting 404 status code. Any help would be highly appreciated.
Regards,
Kailash

Bitbucket Server introduced the API you're talking about in Bitbucket 5.1.0. Prior to that, there was an unsupported Atlassian Labs plugin called the Stash Archive plugin, which provided similar functionality - however it had a slightly different API.
If you're using a version of Bitbucket earlier than 5.1.0, and you already have the above add-on installed, then you can use this very similar REST endpoint:
https://<bitbucket-base-url>/rest/archive/1.0/projects/<projectKey>/repos/<repoSlug>/archive?AT=xyz&filename=xyz.tar.gz&format=.tar.gz
If you don't have the above add-on installed, you can either install it or upgrade Bitbucket to 5.1.0 or higher (5.10.0 is the newest release at the time of writing).
See https://jira.atlassian.com/browse/BSERV-2732 for more background on all of the above.

Related

Is there a way to import a Bamboo Spec file via the REST API?

I currently try to automate the process of creating a new Bamboo linked repository and start the scan. I've already looked over the documentation of the REST API, tried to generate a new plan and enabling a scan, but that didn't work.
I also tried the Java Maven Package from Atlassian, but that needs user credentials as an authentication method, whilst I need to authenticate via a Security token. There is a link to an API in that Maven Package, which I tried to send a request to with the yaml code, but it always responds with the status code 500 and a Java Stacktrace. It's probably due to a wrong request body, but I can't figure out, how to include the yaml content the same way, as the maven package.
Is there a way to create a linked repository via the REST API?
Thanks in advance!
Is there a way to create a linked repository via the REST API?
No and there won't ever be one because they're deprecating the Bamboo server in favour of their cloud-based alternative (which is based on a totally different API). See https://jira.atlassian.com/browse/BAM-18453
Java Maven Package from Atlassian
What package is that? Based on what I said earlier the only way for you to programmatically create a linked repo is to mimic the browser POST request to updateLinkedRepository.action. That means that you'll need to login first to get a JSESSIONID cookie (xsrf token can be disabled, see https://confluence.atlassian.com/bamkb/rest-api-calls-fail-due-to-missing-xsrf-token-899447048.html#RESTAPIcallsfailduetoMissingXSRFToken-Workaround). Ping me if you need help, I still have ansible code for the login part.

TFS 2018 REST API Call for Backlogs // API Version 4.1

we have TFS 2018 and are able to call the following URL using PAT for authorization:
https://our.tfs/tfs/Our.Project.Collection/Our Team Project/_apis/wit/workitems?ids=1234&?api-version=2.0
This quite basic call returns expected results.
Trying to request API calls from the following documentation results always in 404 Page not found:
https://learn.microsoft.com/de-de/rest/api/vsts/work/backlogs/list?view=vsts-rest-4.1
For example:
https://our.tfs/tfs/Our.ProjectCollection/Our Team Project/_apis/work/backlogs?api-version=4.1
which yields the mentioned 404 error.
According Microsoft, the API is supported in version 4.0 on TFS 2018:
https://learn.microsoft.com/en-us/vsts/integrate/concepts/rest-api-versioning?view=tfs-2018
However, it seems calling the API in version 4.1 in the way the documentation describes it here only works for VSTS but not for TFS
Do I understand it correctly that any API calls to API version greater than 4.0 are currently only supported by VSTS but not on TFS on prem?
This would mean we have to live with API calls documented in the "Previous REST API Versions" when using TFS 2018 on prem?
The REST API format you used is incorrect, you missed the Team parameter
The format should be:
GET http://tfs2018:8080/tfs/DefaultCollection/{Project}/{Team}/_apis/work/backlogs?api-version=4.1-preview.1
It works without any issue on my side.
I believe you will get something by taking a look at these links, see
Visual Studio Team Services REST API Reference
REST API Overview for Visual Studio Team Services and Team Foundation Server
I was able to follow this example:
https://{instance}[/{collection}[/{team-project}]/_apis[/{area}]/{resource}?api-version={version}
see what Microsoft speaks about version 4.1 of this doc.
APIs e uso REST comuns
Discussion on TFS MS Apis
Similar discussion
Hugs

Swagger 1.3.7 and Jersey 2.15/2.16 issue: the request entity is in a format not supported by the requested resource

I have a REST API that was working with Jersey 2.6 and Swagger 1.3.7. I read that Jersey 2.9 fixes a warning that I was getting so I upgraded to the latest Jersey 2.16 but then Swagger stopped working. I went back and upgraded one version at a time until I saw that Swagger was working with 2.15 so I settled on that. Now, the PUT API fails with Swagger with the following error:
The server refused this request because the request entity is in a format not supported by the requested resource for the requested method
The API works using FireFox RESTClient and specifying "application/json".
I do have "jersey-media-json-jackson" as a dependency and call "Client client = ClientBuilder.newClient().register(JacksonFeature.class);" in the program.
I tried upgrading Swagger but that did not help.
Has Swagger been verified to work with Jersey 2.15/2.16?
I've recently managed to get swagger-core to work with Jersey 2.16 with a similar issue. Keep in mind they are using the latest version (1.5.X) and not 1.3.X but the same solution will apply.
The problem is most likely with version resolution, specifically, the one of jackson-databind. For some reason, even jersey-media-json-jackson 2.16 depends on an older version of jackson-databind, even though it works fine with the latest version. Without having more details, it would be difficult to suggest a full solution, but you can follow the dependency tree and see the conflicts there.
If you do require further assistance, I'd suggest either using our mailing list, or even better, the IRC channel where we could interact online and resolve it.

Eclipse Mantis Error

When I try to add my Mantis-Repository (V1.2.12) to My Eclipse Juno with The Mantis Plugin (org.eclipse.mylyn_feature.feature.group, V3.8.2) my Eclipse shows this error:
Unable to load projects : Failed getting projects : Error Type: SYSTEM
NOTICE, Error Description: Array to string conversion .
If I continue and try to choose a repository from Mantis, the same error is shown.
My URL is directly pointing to the /api/soap/mantisconnect.php file.
How to fix this problem?
It seems that you're running Mantis over PHP 5.4, which is not possible for the SOAP API since our SOAP layer - nusoap - does not support it.
My suggestion is to update the latest git version (master-1.2.x) and also install the php native soap version. This will make sure that Mantis will not use nusoap and will works as expected with PHP 5.4
References:
Mantis SOAP API documentation
Bug report for PHP 5.4 support for the SOAP API

Connecting to Jira remotelly Using Netbeans or other client tools

I am using Atlassian JIRA™ (Professional Edition, Version: 3.0.3-#75 and Netbeans IDE 7.1
But when trying to validate a connection to Jira from netbeans it gave me this error "Jira RPC services are not enabled"
while I have enabled it and also I enabled allow remote calls in Jira
To be more specific "RPC JIRA Plugin" that I have installed is
The standard JIRA RPC services, both SOAP and XML-RPC.
Plugin Version: 1.1
JIRA version: 3.0
It has
System XML-RPC Services (xmlrpc)
The standard JIRA XML-RPC services.
RPC Field Coordinator (rpcFieldCoordinator)
Issue Service (issueService)
User Service (userService)
Token Manager (tokenManager)
System SOAP Services (soap)
The standard JIRA SOAP services.
Magic Field Validator (magicFieldValidator)
Project Service (projectService)
My global configurations are:
Allow users to vote on issues ON
Allow users to watch issues ON
Allow unassigned issues ON
Cache issues ON
External user management OFF
Logout Confirmation Never
Use Gzip Compression OFF
Accept remote API calls ON
BTW, it is not just netbeans, I got same problem with other tools as well to connect to jira
I will apreciate if my answer be found ASAP .
Thanks
Answering an old question, but I thought someone else might find this useful.
I got the same error today setting up an issue tracker in NetBeans 7.2 and I eventually tracked it down to NetBeans not being able to correctly resolve (using DNS) the (local) host name that was running our JIRA server. When I changed NetBeans to use 'No Proxy' in the main settings, it worked fine.
EDIT: Note that as of version 7.0 of the JIRA server, Atlassian have depracated the SOAP/XML-RPC API, so the JIRA Plugin for Netbeans no longer works. :-(