APIs & Integrations

sujatabh
Member

Webhook

SOLVE

How to get the JSOn inside the function of the url which I have provided for webhooks

0 Upvotes
1 Accepted solution
sujatabh
Solution
Member

Webhook

SOLVE

It is solved from the reference URL- https://community.hubspot.com/t5/APIs-Integrations/Webhook-JSON-Understanding-Extracting-Data/td-p/2...

I have used the code -

$json = file_get_contents('php://input');

// Converts it into a PHP object
$json = json_decode($json, true);
//get lastname, firstname, email from array
if(is_array($json)){
$lastname = $json['properties']['lastname']['value'];
$firstname = $json['properties']['firstname']['value'];
$mobilephone = $json['properties']['mobilephone']['value'];
$email = $json['properties']['email']['value'];
$vid = $json['vid']; // vid; contact specific identifier
}

and got the solution

View solution in original post

6 Replies 6
Willson
HubSpot Employee
HubSpot Employee

Webhook

SOLVE

Hey @sujatabh,

 

Could you clarify what you're trying to access? Are you trying to access data in HubSpot from a Webhook URL you've setup externally? If so, this is not possible, our Webhooks functionality only supports sending data FROM HubSpot to your external Webhook URL.

 

I hope this helps!

Product Manager @ HubSpot
0 Upvotes
sujatabh
Member

Webhook

SOLVE

WhatsApp Image 2020-09-09 at 8.15.41 PM.jpeg

 

how to get this json inside the function of my side(external Webhook URL)

0 Upvotes
sujatabh
Member

Webhook

SOLVE

I have followed some steps to integrate webhook :

Step 1- Created a workflow from the menu Automation that will be triggered when a contact will be created.

Step 2- Then choose Trigger webhook from Action.Put Webhook url.

Step 3- Write some method which will be triggered inside the provided webhook url.

It is triggerering my function when a contact is created.But as per your webhook document(https://knowledge.hubspot.com/workflows/how-do-i-use-webhooks-with-hubspot-workflows),

WhatsApp Image 2020-09-09 at 8.15.41 PM(1).jpegthis type of JSON will be sent through webhook.How can I get it from my function and then want to decode it and use it for make a specific task for a contact.

0 Upvotes
Willson
HubSpot Employee
HubSpot Employee

Webhook

SOLVE

Hey @sujatabh,

 

As this data is sent externally to your Webhook URL, it is up to you to decide what method is best to convert this from JSON into a format you can work with when creating tasks.

 

I am unable to make any recommendations as I do not know how your external tool works or what codebase you're working with. As such, you'll need to work with your team to address this question. 

Product Manager @ HubSpot
0 Upvotes
satishjalan
Member

Webhook

SOLVE

Hi Matthew,

 

We are integrating SMS API using Webhook API from Hubspot.

 

While executing the process, through a https page, we are not getting the json file.

 

However, we know the method to parse/convert it to fetch the data we need which needs to be sent to our SMS API.


So, for this, we created a test workflow, and triggered the webhook. As per the documentation, the https should receive the json file sent by the Hubspot. Now, the only question is that how to get this json file.

 

I hope, I have been able to make my query clear.

 

Sujata, works in my team.

0 Upvotes
sujatabh
Solution
Member

Webhook

SOLVE

It is solved from the reference URL- https://community.hubspot.com/t5/APIs-Integrations/Webhook-JSON-Understanding-Extracting-Data/td-p/2...

I have used the code -

$json = file_get_contents('php://input');

// Converts it into a PHP object
$json = json_decode($json, true);
//get lastname, firstname, email from array
if(is_array($json)){
$lastname = $json['properties']['lastname']['value'];
$firstname = $json['properties']['firstname']['value'];
$mobilephone = $json['properties']['mobilephone']['value'];
$email = $json['properties']['email']['value'];
$vid = $json['vid']; // vid; contact specific identifier
}

and got the solution