Getting Data In

webhook: unable to read POST data

sistemistiposta
Path Finder

Hello Splunk users,
I'm sorry for this trivial question, but I can't understand.

How can I read the HTTP POST data from webhook alert action?

I wrote this webhook script:

<?php

file_put_contents('postalert', print_r($_POST, true));

?>

But when it triggers, I only see an empty array as result:

Array
(
)

I'm sad. Where am I wrong?

Thank you very much

Warm Regards
Marco

1 Solution

daxsmartpak
Engager

I was having the same issue and was able to find the answer with the following StackOverflow article, excerpted here:

The PHP superglobal $_POST is only is supposed to wrap data that is either

  • application/x-www-form-urlencoded (standard content type for simple form-posts) or
  • multipart/form-data-encoded (mostly used for file uploads)

You need to fetch it yourself in RAW format with:
file_get_contents('php://input')

https://stackoverflow.com/questions/8893574/php-php-input-vs-post

View solution in original post

0 Karma

daxsmartpak
Engager

I was having the same issue and was able to find the answer with the following StackOverflow article, excerpted here:

The PHP superglobal $_POST is only is supposed to wrap data that is either

  • application/x-www-form-urlencoded (standard content type for simple form-posts) or
  • multipart/form-data-encoded (mostly used for file uploads)

You need to fetch it yourself in RAW format with:
file_get_contents('php://input')

https://stackoverflow.com/questions/8893574/php-php-input-vs-post

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...