Error in creating the custom workflow action

rajnishpatel
Member
Hi all,

I tried to create my own custom workflow action in Hubspot using my app id and developer API key . But I am getting a 404 error.

I have followed  the API documentation  to create the workflow action.

I have followed both the older and newer version of API documntation.

New API docs: https://developers.hubspot.com/docs/api/automation/custom-workflow-actions

 

older API docs: https://legacydocs.hubspot.com/docs/methods/workflow-extensions/workflow-extensions-overview

 

I searched for the solution but I didn't find any.

Please help me get out of this problem.

 

Thanks and Regards

Rajnish Patel 

0 Upvotes
9 Replies 9
dennisedson
Community Manager

@rajnishpatel ,

Could you add your code that you are using so we can see?

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
0 Upvotes
rajnishpatel
Member

Hi dennisedson,

This code I am using

curl --request POST \
--url https://api.hubapi.com/automationextensions/v1/definition?hapikey=<<Developer API key >>&applicationId=407547
--header 'content-type: application/json' \
--data '{

{
"integrationAppId": 407547,
"extensionName": "Mahakaal Action",
"webhookUrl": "url",
"fieldMetadata": [{
"label": "Phone",
"key": "phone",
"required": true,
"fieldType": "TEXT",
"values": [{
"type": "OBJECT_PROPERTY"
}]
},
{
"label": "Email",
"key": "email",
"required": false,
"fieldType": "TEXT",
"values": [{
"type": "STATIC_VALUE",
"allowsMergeTags": true
}]
},
{
"label": "Message",
"key": "message",
"required": true,
"fieldType": "TEXTAREA",
"values": [{
"type": "STATIC_VALUE",
"allowsMergeTags": true
}]
}]
}
0 Upvotes
webdew
Top Contributor | Diamond Partner

Hi @rajnishpatel ,

Please try with below code:

<?php

$url = 'https://api.hubapi.com/automationextensions/v1/definitions?hapikey=<Developer_HUBSPOT_KEY>&applicationId=<Developer_APP_ID>';
$data = '{
"integrationAppId": <Developer_APP_ID>,
"extensionName": "<NAME>",
"webhookUrl": "https://<Domain>/workflow_WebHook",
"dataUrl":"https://<Domain>/workflow_WebHook",
"fieldMetadata": [
{
"label": "Email",
"key": "email",
"fieldType": "TEXT",
"values": [
{
"type": "STATIC_VALUE",
"allowsMergeTags": true
}
]
},
{
"label": "Mobile Number",
"key": "phone_number",
"fieldType": "TEXT",
"values": [
{
"type": "STATIC_VALUE",
"allowsMergeTags": true
}
]
},
{
"label": "DLT ID",
"key": "DLT_key",
"fieldType": "TEXT",
"values": [
{
"type": "STATIC_VALUE",
"allowsMergeTags": true
}
]
},
{
"label": "Message",
"key": "message",
"fieldType": "TEXTAREA",
"values": [
{
"type": "STATIC_VALUE",
"allowsMergeTags": true
}
]
}
]
}';



$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);

if (curl_errno($ch))
{
echo 'Error:' . curl_error($ch);
}
curl_close($ch);

Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regard.

 

0 Upvotes
rajnishpatel
Member

Hi @webdew ,

Is there any problem with the workflow API due to which I am getting error while creating custom workflow action?

 

0 Upvotes
rajnishpatel
Member

Hello @webdew ,

Your code is not working. Let's connect and have a one-to-one discussion.

0 Upvotes
rajnishpatel
Member

Hi @webdew ,

Thank you so much for the PHP code but this time I am getting this  error : HTTP error 404  Resouce Not Found

 
I am running the PHP file with the help of xampp 
0 Upvotes
rajnishpatel
Member

I also run this code in the php code editor of w3 schools.

Error I am getting there is:

Could not resolve host: api.hubapi.com

0 Upvotes
webdew
Top Contributor | Diamond Partner

@rajnishpatel , Your path is not correct. Please go to xampp folder, then create any folder inside htdocs and then create index.php

Path like :
xampp/htdocs/project/index.php

index.php
<?php
$url = 'https://api.hubapi.com/automationextensions/v1/definitions?hapikey=<Developer_HUBSPOT_KEY>&applicationId=<Developer_APP_ID>';
$data = '{
"integrationAppId": <Developer_APP_ID>,
"extensionName": "<NAME>",
"webhookUrl": "https://<Domain>/workflow_WebHook",
"dataUrl":"https://<Domain>/workflow_WebHook",
"fieldMetadata": [
{
"label": "Email",
"key": "email",
"fieldType": "TEXT",
"values": [
{
"type": "STATIC_VALUE",
"allowsMergeTags": true
}
]
},
{
"label": "Mobile Number",
"key": "phone_number",
"fieldType": "TEXT",
"values": [
{
"type": "STATIC_VALUE",
"allowsMergeTags": true
}
]
},
{
"label": "DLT ID",
"key": "DLT_key",
"fieldType": "TEXT",
"values": [
{
"type": "STATIC_VALUE",
"allowsMergeTags": true
}
]
},
{
"label": "Message",
"key": "message",
"fieldType": "TEXTAREA",
"values": [
{
"type": "STATIC

Hope this helps!


If we were able to answer your query, kindly help the community by marking it as a solution.

Thanks and Regard.

0 Upvotes
rajnishpatel
Member

Hello @webdew ,

Created a folder in the htdocs named as project and inside it index.php.

But getting same error.  404 error resource not found.

Have you created any custom workflow action with the php code you provided me?

 

Can we conect and then discuss.

0 Upvotes