Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Push Webhook only sends an empty array for Payload

Arnold Bailey August 5, 2015

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

3 votes
Answer accepted
Brian Edwards
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 6, 2015

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

 

Arnold Bailey August 6, 2015

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.

Brian Edwards
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 6, 2015

That is coming soon.

0 votes
Brian Edwards
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 6, 2015

What are you using to consume the webhook payload?

Arnold Bailey August 6, 2015

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
TAGS
AUG Leaders

Atlassian Community Events