Introduction

 

Webhooks are a powerful Jive feature that allow you to subscribe to events that occur in the system. For example, you can subscribe to all user account creations, or all the new documents that are created in a particular Place. The subscription basically tells Jive to send a JSON object (of the content you want) to whatever endpoint you've specified.

 

The Jive documentation mentions creating some kind of add-on/extension and subscribing using a Tile, but it's actually possible use a tool like Postman to talk to the Webhook REST API to register a hook, or manage all the webhooks that are set up on your Jive instance.

 

Note; we run our community in a /community sub-folder.. so if you're following this guide, take that into account for any URLs you're copying.

 

oAuth2 Add-On

 

The first thing you need to do is install a pretty generic oAuth2 add-on. This was originally provided in this document, but I've altered meta.json to have a callback URL linked to Postman. I've attached the add-on to this document.

 

Note; uninstalling the add-on will remove any webhooks you set up against it.

 

 

oauth1.png

 

Setting Up Postman

 

Next, you need to follow these steps to set up Postman to use an OAuth 2.0 access token.

 

oauth2.png

 

oauth3.png

 

PHP Debugger

 

As you can see, in step (9) I'm telling the webhook to talk to a PHP page. This is a dead simple debug page I set up to see what the webhook payload looked like, and to test that the whole thing was working. It'll send the contents of any request to a log file.

 

Here's the code;

 

<?php
    $todays_date = date("Y-m-d G:i:s");
    $requestBody = array2string($_REQUEST);
    $entityBody = file_get_contents('php://input');
    
    $fp = fopen("webhooks.log", "at");
    fwrite($fp, "$todays_date -> $requestBody --> $entityBody\n\n");
    fclose($fp);

    function array2string($data){
        $log_a = "";
        foreach ($data as $key => $value) {
            if(is_array($value))    $log_a .= "[".$key."] => (". array2string($value). ") \n";
            else                    $log_a .= "[".$key."] => ".$value."\n";
        }
        return $log_a;
    }    
?>

 

 

Further Reading

 

Webhooks API documentation

https://developers.jivesoftware.com/api/v3/cloud/rest/WebhooksService.html

 

The post which set me on the right track to get Postman to talk to Jive

https://community.jivesoftware.com/message/1588488

 

Original oauth2 add-on.

https://community.jivesoftware.com/docs/DOC-97348