2 Questions: Request_uri is confusing, Webhook not firing - SOLVED


#1

Following your instructions, I’ve created an app which is supposed to fire a webhook when dealstate changes. According to your instructions, I create a URL that looks like this:

https://app.hubspot.com/oauth/authorize?client_id=xxxx-xxxx-xxxx-xxxx-xxxx&scope=contacts+content+reports+files+hubdb&redirect_uri=https://www.hubspot.com

I click on it, select a test portal, click to allow, and I get redirected to here:

(This does not seem right to me, I think the request URI should be my own page which does the following:)

So I copy and paste the code parameter to my own page URL which does this:

https://hooks.MYDOMAIN.com/hubspot.php?code=xxxx-xxxx-xxxx-xxxx-xxxx

$encoded='';

$arr=[
        'grant_type' => 'authorization_code',
        'client_id' => 'xxxxxxxxxx',
        'client_secret' => 'xxxxxxxxxx',
        'redirect_uri'=> 'https://www.hubspot.com',
        'code' =>  $_GET['code']
];

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://api.hubapi.com/oauth/v1/token");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

foreach($arr as $name => $value) {
        $encoded .= urlencode($name).'='.urlencode($value).'&';
}

$encoded = substr($encoded, 0, strlen($encoded)-1);

curl_setopt($ch, CURLOPT_POSTFIELDS,  $encoded);

curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/x-www-form-urlencoded;charset=utf-8'
    ));

$result = curl_exec($ch);

echo $result;

curl_close($ch);

And I get output that looks like this:

{“refresh_token”:“xxx-xxx-xxx-xxx-xxx”,“access_token”:“XXXXXXXXXXXXXXXXXX”,“expires_in”:21600}

Lovely! The integration shows up on the integrations page, and the app settings show 1 install.

Except for 2 issues / confusions:

ITEM #1. I’m assuming that the request_uri is really supposed to be my own PHP page and not hubspot.com, however all of your examples and responses to “is this url correct?” questions in posts lead one to believe that it should be hubspot.com which makes no sense.

ITEM #2. Webhook isn’t firing? It’s in the app, it’s active, but if I go to wehbook logging it says this:

And under Webhook Subscriptions it says this:

And “Configure” has my webhook URL, and testing it is successful and I can see the entry in my access log too. But even though there’s a green dot and it says “Active” and everything is configured, I can’t make this go away:

The integration is installed in portal 3336670, but when I move deals from state to state, nothing hits my webhook.

Can you please shed some light or clarifications on these 2 things?


#2

In another thread someone confirmed that no, the request_uri should not be hubspot.com, that would be useless. Unless you are planning on copy and pasting the code to the authorization URL manually, this parameter should be your own handler that performs the next step in the operation.


#3

I rebuilt the app from start and installed it in my test portal. I added “automation” scope this time. I’m still not getting any webhook hits and I have that funny condition where the it has the green dot and says “Active”, but the “Activate” link is not available and it has that tooltip.


#4

I don’t know if adding the “automation” scope was necessary, but then I noticed that I had used the property name “dealstate” when it should have been “dealstage” and voila it works. There doesn’t seem to be any error checking on property name because I guess that would not be possible since those property names are dynamic.

I still can’t get the “You must configure…” tooltip to go away even though it is configured and active. I guess that doesn’t matter as long as it’s working, but I bet that would really confuse some people (like me) who are struggling to accomplish this monumental feat :slight_smile: