Setup: A node web application that queries the bitbucket api. For testing I am using an app password tied to my personal user account. I have turned the requests into standard curl commands to demonstrate the issue.
The first request works without a problem (responses truncated)
$ curl -sL --user "$BITBUCKET_CLOUD_USERNAME:$BITBUCKET_CLOUD_PASSWORD" 'https://api.bitbucket.org/2.0/workspaces/<WORKSPACE REDACTED>/search/code?page=1&pagelen=100&search_query=%22catalog-info.yaml%22+path%3Acatalog-info.yaml' | jq . | head
{
"size": 712,
"page": 1,
"pagelen": 100,
"next": "https://api.bitbucket.org/2.0/workspaces/%7Be986b1b2-873b-4c51-8364-9da80494e59b%7D/search/code&search_query=%22catalog-info.yaml%22+path%3Acatalog-info.yaml&pagelen=100&page=2",
"query_substituted": false,
"values": [
{
"type": "code_search_result",
"content_match_count": 4,
The issue comes from the “next” value in the response JSON:
https://api.bitbucket.org/2.0/workspaces/%7Be986b1b2-873b-4c51-8364-9da80494e59b%7D/search/code&search_query=%22catalog-info.yaml%22+path%3Acatalog-info.yaml&pagelen=100&page=2
This is not a valid link, code&search_query
should be code?search_query
, and it is causing errors in my application, since trying to call that link gives me a 404
error:
curl -sL --user "$BITBUCKET_CLOUD_USERNAME:$BITBUCKET_CLOUD_PASSWORD" 'https://api.bitbucket.org/2.0/workspaces/%7Be986b1b2-873b-4c51-8364-9da80494e59b%7D/search/code&search_query=%22catalog-info.yaml%22+path%3Acatalog-info.yaml&pagelen=100&page=2'
{"type": "error", "error": {"message": "Resource not found", "detail": "There is no API hosted at this URL.\n\nFor information about our API's, please refer to the documentation at: https://developer.atlassian.com/bitbucket/api/2/reference/"}}%