POST from HubSpot to external software - where do I write my request body?
Hi
I am writing code to exchange data two-ways between HubSpot and an external softare.
I have received the answer to use WebHooks to make a HTTPRequest (eg. REST API).
Using webhooks I am now able to create (an empty) record in my external software incl basic authorization.
I want to add some data too
When using a REST call I am adding a request body like this … and here you can see how I would solve this issue in some other environment outside HubSpot
var requestBody = “{‘email’:‘anders.thillman@imydomain.com’,‘first_name’:‘Anders’,‘last_name’:‘Thillman’,‘lifecycle_stage’:‘Subscriber’}”;
The coding is for information only. Not part of my question.
I will use this in two different ways
1, Send data about all users to my external software (probably as a loop with multiple records - not one huge ). Thinking about a scheduled job.
2, When the single contact will update for ex lifecycle_stage - a web hook or similar will be triggered. Thinking about the single record being updated.
(FYI: Purpose is data synchronization between the two environments. The same operations will occur in my external software sending data to HubSpot)
Question:
Where in HubSpot do I add my request body-string eg. JSON field according to 1 and 2 ?
*** OR ****
Can I write my own code somewhere in HubSpot? Is the script language javascript ?
It would be nice if you want to provide an example where to write, how to call it and execute it from form submit vs. Webhook or similar.
POST from HubSpot to external software - where do I write my request body?
Hey Anders,
When you’re using a Webhook (specifically, a POST-based Webhook) the information about the contact that triggered the Webhook is automatically included in the request body. You can see an example request body here:
You’ll need to parse through the request body on your end to find specific data you’re looking for.
If you absolutely MUST have a customizable request body, the only way I’m aware to do that is with Zapier - which is a third party integration with HubSpot. Zapier let’s you integrate different “apps” of which HubSpot is one. Another “app” is a Zapier Webhook. If you hook the two together, you can use HubSpot data in a more customizable webhook.
I’d recommend the first option, just to keep the overall complexity low, but the second option is there for you.