Push Webhook only sends an empty array for Payload

In BitBucket I setup a Push webhook. On the receiving side I log the data sent in the post. With a webhook I always get an empty POST array. No Payload.

If I do exactly the same thing using the deprecated Push Services it works fine. So I know I'm triggering it correctly. I even tried leaving both the Service and the WebHook active at the same time. Still blank from the WebHook. Any ideas why?

2 answers

1 accepted

2 votes
Accepted answer

Something like this should work.

$inputJSON = file_get_contents('php://input');
$input= json_decode( $inputJSON, TRUE ); //convert JSON into array

http://stackoverflow.com/questions/7047870/issue-reading-http-request-body-from-a-json-post-in-php

 

That did it. Thanks! Now I find that what is sent doesn't have any of the information I need like what's being pushed. Mutter mutter.

That is coming soon.

0 votes

What are you using to consume the webhook payload?

At this point I'm just logging the POST info to a log file to keep it simple. PHP script <?php error_log(print_r($_REQUEST, true), 3, 'logfile.txt'); Can't get much simpler. Return the following depenfing on whether WebHoook or Service. So it's the right trigger. Array //webook ( ) Array //service ( [payload] => {"repository": {"website": "", "fork": false, "name": "DGC Ticker", "scm": "git", "owner": "arkytn", "absolute_url": "/arkytn/dgc-ticker/", "slug": "dgc-ticker", "is_private": true}, "truncated": false, "commits": [{"node": "8257c2e8e27c", "files": [{"type": "modified", "file": "assets/cmb2/readme.txt"}], "raw_author": "arkytn <abaileytn@gmail.com>", "utctimestamp": "2015-08-06 14:46:16+00:00", "author": "arkytn", "timestamp": "2015-08-06 16:46:16", "raw_node": "8257c2e8e27ca634b197c2e86c8b88588e0159f4", "parents": ["2546922f721e"], "branch": "master", "message": "Deploy test\n", "revision": null, "size": -1}], "canon_url": "https://bitbucket.org";, "user": "arkytn"} )

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

244 views 3 7
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you