I’m having trouble sending data through cURL POST requests to a webhook endpoint. The webhook works perfectly when I access it directly through browser GET requests with query parameters, but fails when using cURL POST method.
Working browser request format:
When I visit the URL directly with parameters in the query string, the webhook receives the data successfully.
Your webhook docs say it wants JSON, but you’re sending form data. That’s the main problem here. Fix your CURLOPT_POSTFIELDS line with json_encode(array('user_id' => $_POST['user_id'], 'title' => $_POST['title'], 'contact' => $_POST['contact'])) and add these headers: CURLOPT_HTTPHEADER => array('Content-Type: application/json', 'Accept: application/json'). Most webhooks I’ve worked with are picky about getting the right format.
you’re mixing up javascript and php syntax - use dots, not plus signs for concatenation. try http_build_query($_POST) instead of building the string manually. it’s cleaner and handles encoding automatically.
Yeah, everyone’s catching the syntax and JSON issues (good catches), but you’ve got a bigger headache coming. Manual webhook handling turns into a nightmare once you scale.
I’ve done this dance way too many times. You fix one webhook, need another, add error handling, then retries, then logging. Suddenly you’re running a whole webhook infrastructure.
Stop wrestling with cURL every single time. Automate it. Build your webhook workflows once and let the platform handle the technical garbage - JSON formatting, errors, retries, monitoring.
What you’re doing works for one-offs, but connecting multiple services or adding logic? You’ll rewrite everything. Automation platforms handle these integrations without the cURL debugging hell.
Drag, drop your webhook endpoint, map your fields, done. No syntax errors, no content-type headaches, no maintenance.
Your webhook expects JSON but you’re sending form data. Set the content-type to application/json and use json_encode($_POST) for POSTFIELDS instead of a query string. Drop the CURLOPT_POST option too since you’ve got CURLOPT_CUSTOMREQUEST. I’ve hit this same problem - it’s almost always the content-type mismatch.
debug the actual response first - add curl_error($ch) and curl_getinfo($ch, CURLINFO_HTTP_CODE) before closing the handle. bet you’re getting a 400 error that’s being ignored. also check if the webhook url needs a trailing slash