We are trying to search specific text in Bitbucket Commits from our JAVA Code. We need to use REST web service for it
We tried to use APT /2.0/repositories/{username}/{repo_slug}/commits but it return all commits of this repository
We only need those commit details which having specific text says "xyz"
Again we found one code search API https://api.bitbucket.org/2.0/teams/{username}/search/code here it give error : Server returned HTTP response code: 405 Method Not Allowed
String commitsUrl="https://api.bitbucket.org/2.0/teams/"+bitbucketUsername+"/search/code";
URL url = new URL(commitsUrl);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("GET");
String encoded = Base64.getEncoder().encodeToString((bitbucketUsername+":"+bitbucketPasscode).getBytes(StandardCharsets.UTF_8));
connection.setRequestProperty("Authorization", "Basic "+encoded);
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setDoOutput(true);
String body = "search_query="+search_query;
os = connection.getOutputStream();
os.write(body.getBytes(StandardCharsets.UTF_8));
connection.connect();
br = new BufferedReader(new InputStreamReader((connection.getInputStream())));
Showing Error: 405 Method Not Allowed at
Expected: Returning some JSON as per description in link https://developer.atlassian.com/bitbucket/api/2/reference/resource/teams/%7Busername%7D/search/code