Sending HTTP POST Request to Zapier Webhook Using cURL in PHP

I’m having trouble sending data to a Zapier webhook using PHP cURL. The webhook works fine when I access it directly through the browser with GET parameters, but my PHP cURL POST request isn’t working.

Here’s my current PHP code:

<?php
    // Set up cURL session
    $ch = curl_init();
    
    // Build POST data string
    $postData = 'user_id=' . $_POST['user_id'] . '&title=' . $_POST['title'] . '&user_email=' . $_POST['user_email'];
    
    // Configure cURL settings
    $options = array(
        CURLOPT_URL => 'https://zapier.com/hooks/catch/n/xyz123',
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => $postData,
        CURLOPT_HTTPHEADER => array(
            'Content-Type: application/x-www-form-urlencoded'
        )
    );
    
    // Apply settings
    curl_setopt_array($ch, $options);
    
    // Execute request
    $response = curl_exec($ch);
    
    // Clean up
    curl_close($ch);
    
    print $response;
?>

The script runs without errors and shows a success message, but Zapier doesn’t receive the data. I noticed that Zapier’s documentation shows JSON format for POST requests. Should I be sending JSON data instead of form-encoded data? What am I missing in my implementation?

You’re right about the JSON format. Had this same problem last year with Zapier webhooks. Zapier wants JSON payload for POST requests, not form-encoded data. Use json_encode() on your data array for $postData, and change the content-type header to application/json. Also add CURLOPT_HTTPHEADER with Content-Length header - this fixed my issues where the webhook looked successful but data wasn’t getting through. Check Zapier’s webhook history in their dashboard to see what they’re actually receiving.

yeah, zapier def prefers json for webhooks. try using json_encode() for your postfields and set content-type to application/json. also, don’t forget to add CURLOPT_HTTPHEADER with the json header. that should do it!

Yeah, it’s definitely the data format. Zapier webhooks need JSON for POST requests, but you’re missing another step. After switching to JSON with json_encode(), you need to handle the response properly. I had the same issue - everything looked fine but data wasn’t hitting the zap. Turned out I wasn’t checking for cURL errors. Add curl_error($ch) and curl_getinfo($ch, CURLINFO_HTTP_CODE) to see what’s actually happening. Also, sanitize your POST data before encoding to JSON - unescaped characters will silently break the JSON structure. The webhook might return 200 OK but still reject malformed JSON.