1. Bitbucket
  2. Public Issue Tracker
  3. master
  4. Issues

Issues

Issue #9255 invalid

"Pull Request POST" hook not sending any data in request

qwe
created an issue

I am receiving http request, but no post data is present. Same thing when creating PR, approving or commenting. When using same script with "POST" hook it works fine, all data is received, so i guess its not problem with php script.

I was testing those hooks in repo eyveer/testing.

Receiveing script:

<?php 


file_put_contents('logpost', "\n\nRequest received\n" , FILE_APPEND);
file_put_contents('logpost', "\n\n" . var_export($_POST, true) . "\n" , FILE_APPEND);

$json = isset($_POST['payload']) ? str_replace('\\','',$_POST['payload']) : false;
if (!$json) {
    return false;
}

$data = json_decode($json);
file_put_contents('logpost', var_export($data, true) , FILE_APPEND);

Comments (13)

  1. Kaleb Elwert

    For now, I'm going to leave this as-is. However, this is not a bug. The original POST hook provided the JSON data in a "payload" POST variable, however this is an older method of doing things. In the newer Pull Request POST hook, we simply provide a Content-Type of application/json and include the data as the raw POST data. We have no intention of making any backwards incompatible changes with either of these hooks, so your best bet is to have a separate endpoint which manages pull request hooks.

    This is a modified version of your sample code which will pull the json into the $data variable.

    <?php
    
    $json = file_get_contents('php://input');
    if (!$json) {
        return false;
    }
    
    $data = json_decode($json);
    

    https://confluence.atlassian.com/display/BITBUCKET/Pull+Request+POST+hook+management

  2. Log in to comment