1
I’m trying to make a POST request so I can register a product using Curl but when I run it returns me an empty string
$param_POST = array(
"IdProduct"=> "000001",
"Name"=> "Caixa de Som",
"Code"=> "125241",
"Brand"=> "JBL",
"NbmOrigin"=> "11111",
"NbmNumber"=> "",
"WarrantyTime"=> "0",
"Active"=> true,
"Categories"=> array(
"Id"=> "1",
"Name"=> "teste",
"ParentId"=> ""
),
"Attributes"=> array(
"Name"=> "Protecao",
"Value"=> "resistente a agua"
)
);
$GetMarketplace = Integra_POST('/api/Product',$param_POST);
var_dump($GetMarketplace);
This is the array I send to my function with endpoint and array.
function Integra_POST($endpoint, $params = array()){
//Execução de POST
$url = $_SESSION['url'];
$url .= $endpoint;
$data = json_encode($params);
$ch_opts = integra_GetCurlOpts();
$ch_opts[CURLOPT_CUSTOMREQUEST] = "POST";
$ch_opts[CURLOPT_POSTFIELDS] = $data;
$ch_opts[CURLOPT_HTTPHEADER] = array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data)
);
echo $data;
$ch = curl_init($url);
curl_setopt_array($ch, $ch_opts);
$result = curl_exec($ch);
return $result;
}
my Curl already has these parameters but on another page php Porq I’m not only using a function so the main I left separate, still I tried to put in the same file and it still didn’t work
– user175313