I'm trying to make a post request to salesforce "api".
however it accepts only content type which is explicitly set to "application/x-www-form-urlencoded"
When I do this:
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://www.salesforce.com/servlet/servlet.WebToLead',
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_POST => 3,
CURLOPT_POSTFIELDS => json_encode(array (
'first_name' => 'foo',
'last_name' => 'faa',
'email' => 'my.email@gmail.com',
'oid' => '#hash',
'recordType' => '#hash'
)),
CURLOPT_HTTPHEADER=>array(
'Content-type: application/x-www-form-urlencoded'
)
));
$data = curl_exec($ch);
$info = curl_getinfo($ch);
The response headers content-type is always:
"text/html;charset=UTF-8"
The same parameters I send using postman (with the correct header) actually works.