[Bitbucket] JSON
Bitbucket Repository
Calls a Bitbucket respository to obtain the contents of your specified API schema.
Authorization
This Request uses OAuth 2.0 to authorize the Request. You will need to take the following steps in Bitbucket, and store the following information for this request to work:
- Select your avatar (Your profile and settings) from the navigation bar at the top right.
- Under Recent workspaces, select the workspace that will be accessed using the consumer; or find and open the workspace under All workspaces.
- At the top right, click the gear icon and select the Workspace settings.
- On the left sidebar, under Apps and features, select OAuth consumers.
- Click the Add consumer button.
- Enter a Name and use
https://oauth.pstmn.io/v1/browser-callback
for the Callback URL. - For Permissions, select the checkbox for Read under Projects and click the Save button.
- Once created, click the name of the OAuth consumer to view the Key and Secret.
- Store this information somewhere secure where you can access it again easily.
Now that you have this information stored, click into the Authorization tab of this Request. On this tab, use the following steps:
- Type: OAuth 2.0
- Add authorization data to: Request Headers
- Token Name: [any recognizable name]
- Grant Type: Authorization Code
- Auth URL:
https://bitbucket.org/site/oauth2/authorize
- Access Token URL:
https://bitbucket.org/site/oauth2/access_token
- Client ID: [your stored Key] - update the associated Collection Variable
- Client Secret: [your stored Secret] - update the associated Collection Variable
- Scope: [leave empty]
- State: [optional]
- Client Authentication: Send as Basic Auth header
Format your request
The URL will need to use your Bitbucket workspace and repository slug, branch name and the file path.
- To get your workspace slug, go to the workspace overview page and check the URL. It will be formatted like so:
https://bitbucket.org/{workspace slug}/workspace/overview
. The workspace slug will follow the domain name. - To get your repository slug, go to the repository in your workspace and check the URL. It will be formatted like so:
https://bitbucket.org/{workspace slug}/{repository slug}/src/main/
. The repository slug will follow the workspace slug. - You will find your branch name on the main page of the repository.
- The file path is a combination of the directory in which your schema file is located, along with the schema file name.
Update the following Collection Variables with your Bitbucket information:
bitbucketWorkspaceSlug
bitbucketRepositorySlug
bitbucketBranch
bitbucketFileNameJSON
You can now send a Request to any stored file in your Bitbucket repo.
If you need assistance on how to properly format your Request to your Bitbucket repository, please see Bitbucket's REST API documentation here: https://developer.atlassian.com/cloud/bitbucket/rest/intro/
Example request:
https://api.bitbucket.org/2.0/repositories/[workspaceSlug]/[repositorySlug]/src/[branchName]/[fileName]
Overview
Pre-request Script tab
Sends a message to the Console that the Request is starting to acquire your specified Git repository.
Tests tab
- Checks for a 200 HTTP response to confirm that the schema information was acquired.
- Parses the Response that is returned.
- Sets the JSON that is obtained from your Git repo as the value for
jsonSchemaFromRepo
Collection Variable. - Adds extra formatting to this JSON so it can be successfully passed back into the Qodex API and sets this to
jsonSchemaFromRepo_escaped
Collection Variable.