# Send Webhook Trigger from Campain

**URL:** <https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [October 5, 2022, 10:46pm UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597 "2022-10-05T22:46:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![hanselstange](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/hanselstange/32/6703_2.png) [@hanselstange](https://forum.mautic.org/u/hanselstange)\
**Post date:** [October 5, 2022, 10:46pm UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597/1 "2022-10-05T22:46:52Z")

</div>

**Your software**  
My Mautic version is: v4.4.3  
My PHP version is: 7.4  
My Database type and version is: 10.6.7-MariaDB

My problem is:  
Send Webhook Trigger from Campain

These errors are showing in the log:  
Último error de ejecución: cURL error 28: Operation timed out after 30001 milliseconds with 0 bytes received (see [libcurl - Error Codes](https://curl.haxx.se/libcurl/c/libcurl-errors.html)) for https://

Steps I have tried to fix the problem:  
reproduce PHP code to test cURL is available and diagnostic.

php testing code work fine with :

```auto
$payload=array(...)
CURLOPT_POSTFIELDS => http_build_query($payload)

```

and php testing code fail with :

```auto
CURLOPT_POSTFIELDS => array(...)

```

Some Ideas ?

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [October 6, 2022, 10:53am UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597/2 "2022-10-06T10:53:58Z")

</div>

Can you send through how your web hook looks inside the campaign.

We use web hooks heavily and have not encountered this before. As a test what you can also do is in Settings → Webhooks, go and define a test web hook with your endpoint, set the web hook to fire off for example on a form submission, go and do a form submission and see if you are getting an error on that as well

---

<div class="post-metadata">

**Author:** ![hanselstange](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/hanselstange/32/6703_2.png) [@hanselstange](https://forum.mautic.org/u/hanselstange)\
**Post date:** [October 6, 2022, 4:32pm UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597/3 "2022-10-06T16:32:06Z")

</div>

This is the screen :

 ![Selección_846](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/4/4583102815e479693b3f47e9939a1c4dfc776764.png)

---

<div class="post-metadata">

**Author:** ![hanselstange](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/hanselstange/32/6703_2.png) [@hanselstange](https://forum.mautic.org/u/hanselstange)\
**Post date:** [October 6, 2022, 4:42pm UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597/4 "2022-10-06T16:42:12Z")

</div>

I have a partial solution generating a php proxy file, this give me a more details debugging webhook process

Mautic send post body (form … multipart) and you can capture only with php://input

the other application are waiting for a POST array.

my proxy solution :

```auto
$values = file_get_contents('php://input');
$post="";
parse_str($values, $post);
$msg = $post["message"];
$id = $post["id"];
$key = $post["key"];
// TODO: add value testing code
$curl = curl_init();
$payload = [
  'id' => $id,
  'message' => $msg
];
curl_setopt_array($curl, array(
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_URL => $url . "?key=" . $key,
  CURLOPT_USERAGENT => 'Mautic Connector',
  CURLOPT_POST => 1,
  CURLOPT_POSTFIELDS => http_build_query($payload)
));
$resp = curl_exec($curl);
curl_close($curl);
file_put_contents("../../tmp/webhook.log",($resp.PHP_EOL),FILE_APPEND);

```

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [October 6, 2022, 5:36pm UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597/5 "2022-10-06T17:36:42Z")

</div>

Hi, what is the ‘key’ ?

---

<div class="post-metadata">

**Author:** ![hanselstange](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/hanselstange/32/6703_2.png) [@hanselstange](https://forum.mautic.org/u/hanselstange)\
**Post date:** [October 6, 2022, 6:40pm UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597/6 "2022-10-06T18:40:11Z")

</div>

is a secret

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [October 6, 2022, 7:53pm UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597/7 "2022-10-06T19:53:04Z")

</div>

This secret destroys your api call

---

<div class="post-metadata">

**Author:** ![hanselstange](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/hanselstange/32/6703_2.png) [@hanselstange](https://forum.mautic.org/u/hanselstange)\
**Post date:** [October 7, 2022, 12:13pm UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597/8 "2022-10-07T12:13:27Z")

</div>

Sorry, I don’t understand, using my self made PHP proxy the call Works Fine, but debugging Mautic call I get confused about standard call, because Mautic call is mixing POST methods and body construction,  
I get from Mautic a body with :  
`var1=value1&var2=value2&var3=value3`  
but only can read this body using php://input  
My API is waiting for $\_POST array and I made this translation on my PHP proxy

With my PHP proxy all work fine, but i think is not the best solution add a patch/fix in the middle of two solutions.

I mess some parameters/configurations on my Mautic deploy ? or we can suggest a eventually Mautic improvement in this calls ?

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [October 7, 2022, 12:26pm UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597/9 "2022-10-07T12:26:08Z")

</div>

Hi, sorry I probably misunderstood the purpose of your code.  
No, there are no special configs related to webhooks.  
I usually just make a webhook.site, see what’s coming and adjust my code.

---

<div class="post-metadata">

**Author:** ![leoschuler](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/leoschuler/32/4798_2.png) [@leoschuler](https://forum.mautic.org/u/leoschuler)\
**Post date:** [October 8, 2022, 3:45am UTC](https://forum.mautic.org/t/send-webhook-trigger-from-campain/25597/10 "2022-10-08T03:45:25Z")

</div>

maybe if you include a header called `content-type` / value `application/x-www-form-urlencoded`  
it will help the API recognize the post body ;  
`var1=value1&var2=value2&var3=value3`  
is the format expected

you can also change the format to json by adding the header “content-type” / value “application/json” that will change the body format from form multipart to json, perhaps this is the format your api expects?
