APIs & Integrations

Peta_APB
Contributor | Gold Partner
Contributor | Gold Partner

Workflow webhooks with nested parameters

SOLVE

Hi all

 

Just wondering if someone can point me in the right direction with how to convert nested data into form data in a workflow webhook?

Pretty simply, I’m just configuring a POST webhook to an external application and the expected payload is in CURL.

I really just wanted some help on how to configure the nested parameters in the request body

I have the API documentation for an external application and want to send a POST webhook from a workflow in Hubspot, however I just need to understand how to configure the request body in Hubspot and keep getting a 422 error.

 

I can do this quite easily in Zapier using form data, but would prefer to be able to send it directly from Hubspot if I can.

In Zapier it’s simply using a double-underscore, eg:

 

details__legalType
details__sortCode
details__accountNumber

 

Unfortunately, this doesn’t work in Hubspot. I’ve tried single underscore, but this fails as well. Is there any information on this somewhere? Can anyone help? 

 

This is the expected payload, so I'm fine with everything apart from the 3 nested parameters:

curl -X POST "https://api.sandbox.transferwise.tech/v1/accounts" \
     -H "Authorization: Bearer <your api token>" \
     -H "Content-Type: application/json" \
     -d '{ 
          "details": {
           "legalType": "PRIVATE",
           "sortCode": "40-30-20",
           "accountNumber": "12345678"
           }
        }'




0 Upvotes
1 Accepted solution
LMeert
Solution
Guide | Platinum Partner
Guide | Platinum Partner

Workflow webhooks with nested parameters

SOLVE

Hi @Peta_APB,

 

You cannot customize the body of the webhook action in workflows to have nested fields.

It only sends flat JSON (unless there's a secret, undocumented method for that ? @Teun@Anton)

There are two workarounds I can think of :

  1. This one works for sure but you'll need an operations hub pro subscription : use the custom code action to make a custom API call using either Axios (NodeJS) or Requests (Python)

  2. This one I haven't tried it till the end but I don't see why this wouldn't work :
    Use a custom property named 'details' and format it using the "format data" action
    LMeert_0-1675763484876.png

    Use the custom mode and concat function to format the inside of the "details" key.

    Then set up your webhook like so :

    LMeert_1-1675763624028.png


    If this works for this specific use case that's nice, but if at some point you need a more advanced customisation (like support of an OAuth flow for authentication) you will have to find another way.
    (Either the custom code action from the Pro subscrption or a webhooks to a third party solution like make.com).

Hope this helps !
If it does, please consider marking this answer as a solution 🙂

 

Best,

Ludwig

Agence Mi4 - Data DrivenCTO @ Mi4
Hubspot Platinum Partner and Integration Expert

Passionate human, very curious about everything data and automation.

Any problem with Hubspot you need help solving ?

Let me know !

View solution in original post

2 Replies 2
LMeert
Solution
Guide | Platinum Partner
Guide | Platinum Partner

Workflow webhooks with nested parameters

SOLVE

Hi @Peta_APB,

 

You cannot customize the body of the webhook action in workflows to have nested fields.

It only sends flat JSON (unless there's a secret, undocumented method for that ? @Teun@Anton)

There are two workarounds I can think of :

  1. This one works for sure but you'll need an operations hub pro subscription : use the custom code action to make a custom API call using either Axios (NodeJS) or Requests (Python)

  2. This one I haven't tried it till the end but I don't see why this wouldn't work :
    Use a custom property named 'details' and format it using the "format data" action
    LMeert_0-1675763484876.png

    Use the custom mode and concat function to format the inside of the "details" key.

    Then set up your webhook like so :

    LMeert_1-1675763624028.png


    If this works for this specific use case that's nice, but if at some point you need a more advanced customisation (like support of an OAuth flow for authentication) you will have to find another way.
    (Either the custom code action from the Pro subscrption or a webhooks to a third party solution like make.com).

Hope this helps !
If it does, please consider marking this answer as a solution 🙂

 

Best,

Ludwig

Agence Mi4 - Data DrivenCTO @ Mi4
Hubspot Platinum Partner and Integration Expert

Passionate human, very curious about everything data and automation.

Any problem with Hubspot you need help solving ?

Let me know !

Peta_APB
Contributor | Gold Partner
Contributor | Gold Partner

Workflow webhooks with nested parameters

SOLVE

Thanks @LMeert looks like we'd need operations hub for both of those workarounds unless there's a way to flatten the JSON (Zapier uses underscores, but I can't find any documentation about this in Hubspot).

Thanks for your prompt reply though 🙂 I appreciate the help.

0 Upvotes