Freshdesk调用Twilio API发送短信:JSON请求报21604错误求助
Hey there! Let's break down why your Freshdesk webhook is hitting that Twilio error, even though your curl command works perfectly.
The Root Cause
Your curl command uses --data-urlencode, which sends data in the application/x-www-form-urlencoded format that Twilio's Messages API expects. But when you configured Freshdesk to send a JSON payload, Twilio can't parse the To, From, and Body fields from the JSON body—this is exactly why it's complaining about a missing "To" number.
Step-by-Step Fix
Here's how to adjust your Freshdesk webhook setup to match what Twilio needs:
- Switch the request body format: In Freshdesk's webhook settings, stop using JSON and select Form Data (or "x-www-form-urlencoded" if that's an available option).
- Add your parameters as form fields:
- Field name:
To, Value:+19155409999 - Field name:
From, Value:+15109999999 - Field name:
Body, Value:Its Me, Its Me
- Field name:
- Set up Basic Authentication: Twilio requires your Account SID and Auth Token for access. Enable Basic Auth in Freshdesk's webhook settings, use your Twilio Account SID as the username, and your Auth Token as the password (this replicates the
-uflag in your curl command). - Confirm the Content-Type header: Ensure Freshdesk sends either
application/x-www-form-urlencodedormultipart/form-dataas theContent-Typeheader—this usually happens automatically when you select the Form Data format.
Quick Validation Tip
If you want to double-check, you can replicate this fix in Postman by switching from JSON mode to form-data mode. You’ll see it works exactly like your original curl command.
内容的提问来源于stack exchange,提问作者Terry Nichols

