Hello,
we are currently developing a web application that should access (only read) some data (repos, commits and merge requests) from Bitbucket projects via some javascript code.
Now we have read that Bitbucket does not really support CORS access.
But I also found this page: https://developer.atlassian.com/bitbucket/api/2/reference/meta/cors-hypermedia
Can you tell me if there is a way to accomplish what I need?
Thank you
Hello Marko,
Bitbucket supports CORS when used within the REST API as an additional option. The reference documentation you provided is the same source we use internally for reference material. This documentation also applies to Bitbucket cloud REST API v2. With this said, when making your API calls, you will need to provide the options to include your CORS information.
To better help, are you running into an errored response or are you receiving an error message? Any error message, log or output would help us have a further context in the blockers your experiencing.
We look forward to your response so we can help get your Bitbucket access up and running!
Regards,
Stephen Sifers
Hello Stephen,
We are trying to Access the Bitbucket Rest services directly via web browser(Browser is making call to bit bucket service directly no back end service interaction)
We are getting below exception :
XMLHttpRequest at 'http://hostA:7990/rest/api/1.0/projects/FIR/repos/demo/commits'
from origin 'https://hostA:8080'
has been blocked by CORS policy: Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
also above information and this information https://jira.atlassian.com/browse/BSERV-10589
is contradicting
Also CORS header is not present in response, please .
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Seshi,
Thank you for sending over your response errors and the screenshots of your attempt. Something between your communication with the Bitbucket instance and your call is triggering CORS. It might something network or device related which is causing this.
With this said, you will need to include CORS headers within your API calls for them to respond successfully. Could we please attempt an API call with the CORS headers?
Here is an example:
curl -i https://api.bitbucket.org -H "origin: http://bitbucket.com" -X OPTIONS
We look forward to your response to get your API calls working.
Regards,
Stephen Sifers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Stephen,
Thank you for your replay.
i am trying something like below.
I have a web application(Demp App) which is running on port 7443 and it has some UI and from UI we are making call as shown below
i.e, it will not hit the Demo App, but it tries to connect bibucket server and it gives CORS
xhr.get("http://localhost:7990/rest/api/1.0/users/UserId, {
headers: {
"X-Atlassian-Token": "no-check",
"Access-Control-Allow-Origins" : "*",
"Access-Control-Allow-Methods":"OPTIONS",
"Authorization": "Bearer "+accessToken
}});
Please refer below screenshot
Thanks in Advance.
Seshi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.