Issue #4574 open

Document creation of services via REST API (BB-5351)

Chris Reid
created an issue

Allow creation of repository services via the REST API.

Comments (14)

  1. Chris Reid reporter

    Well it would be nice to do both. Really I just need a simple way to automate creating a POST service for each of my repositories. This way I can automate the creation of a repo, as well as any other services that it may be connected to.

    I figured the REST API would be the best place for that.

  2. Chris Reid reporter

    Hey Brad,

    The specific example I have the code working with is a bit convoluted, but below is an example of some code that should get you going in the right direction:

    // some basic variables
    $user = "myuser";
    $pass = "mypass";
    $project_FullName = "My Dynamically Created Repository";
    $project_description = '';
    $project_DomainName = "";
    $owner = 'myuser';
    // project "fields"
    $fields = array(
        'name' => $project_FullName,
        'description' => $project_description,
        'language' => 'php',
        'website' => 'http://'.$project_DomainName,
        'scm' => 'hg',
        'owner' => $owner,
        'is_private' => '1',
    // url to POST to
    $url = "";
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_USERPWD, "$user:$pass");
    //curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    // these two lines are really the ticket ;)
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
    $result = curl_exec($ch);
    $http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    if ($result === FALSE || $http_status != '200')
        // Uho!
        log_error($result, "There was an error creating the repository on bitbucket!");
    // process the returned json
    $json = json_decode($result);
    log($json, "Sucess!");
    // proceed with the rest of the tasks
  3. suwat ch

    Since it is not documented, can we assume this services api will be supported officially (at the minimum similar to other documented apis)? Otherwise, is it like that it will be removed or changed?

  4. Log in to comment