$url = 'https://stg-api.raudhahpay.com/api/collections/VCdgKyzl/bills?include=product-collections.product'; $data = array( "due" => "2020-12-19", "currency" => "MYR", "ref1"=> "RefTest1", "ref2"=> "RefTest2", "customer" => array ( "firts_name" => "Ali", "last_name" => "Farid", "address" => "Perak", "email" => "ali@abc.com", "mobile" => "60136282302", ), "product" => [ array ( "title" => "Package3", "price" => "10.00", "quantity" => "1" ) ] ); $payload = json_encode($data); print_r ($data_string); $ch=curl_init($url); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); // Set the content type to application/json curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json')); // Return response instead of outputting curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Execute the POST request $result = curl_exec($ch); //curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); //curl_setopt($ch, CURLOPT_POSTFIELDS, array("customer"=>$data_string)); //curl_setopt($ch, CURLOPT_HEADER, true); //curl_setopt($ch, CURLOPT_HTTPHEADER, // array( // 'Content-Type:application/json', // 'Content-Length: ' . strlen($data_string) // ) //); //$result = curl_exec($ch); //curl_close($ch);