I am trying to send a POST request using cURL
.
When I do this in POSTMAN(see screenshot)I get HTTP status 400 (which is fine).
However when I do this in the following cURL
I get HTTP status 0 and error Could not resolve: hello.net (DNS server returned answer with no data)
. Anyone know why?
<?php
$url = 'https://hello.net/';
$ch = curl_init($url);
$postdata = array(
"vendorCode"=>"12345",
"email" => "john.smith@gmail.com",
"name" => "john ",
"organization" => "company.org.id",
"organizationUser" => "john.smith.id",
"accountName"=> "company",
"launchProp" => array(
"launchprop" => "ext",
"platform" => "web"
),
"authorizationType"=> "jwt"
);
$jsonDataEncoded = json_encode($postdata);
//Tell cURL that we want to send a POST request.
curl_setopt($ch, CURLOPT_POST, 1);
//Attach our encoded JSON string to the POST fields.
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
//Set the content type to application/json
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
//Execute the request
$result = curl_exec($ch);
$http_status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
echo $http_status, PHP_EOL;
?>
UPDATE: When I put URL google.com I get error 405.