In postman code snippet section I can get the working code of my POST request as below. (Replaced credentials with dummy values)
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://mpop.hepsiburada.com/product/api/products/import',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('file'=> new CURLFILE('/C:/Users/Ozan/Desktop/newProduct.json')),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'User-Agent: dummy_dev',
'Authorization: Basic MGM0N2Q4ODQtZmYyMi00NTFmLThlYjEtNDY3ZDMwMDk1NzgxOlRUcTdReU5oRUdhUw==',
'Cookie: JSESSIONID=FB8184E3FE98EDB7C4BCAB0052E0291'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
I just created a simple test.php file and put that code there and moddified a little.
<?php
echo "Curl Starts! ";
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://mpop.hepsiburada.com/product/api/products/import",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => [
'file'=> new CURLFILE('C:/Users/Ozan/Desktop/newProduct.json')
],
CURLOPT_HTTPHEADER => [
"accept: application/json",
"content-type: multipart/form-data",
'User-Agent: dummy_dev',
'Authorization' => 'Basic ' . base64_encode( 'dummyMerchantId' . ':' . 'dummySecretKeyPassword')
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
echo "Curl Ends! ";
?>
For some reason I get forbidden error as below:
Curl Starts! {"timestamp":"2024-03-29T12:45:45.064+0000","status":403,"error":"Forbidden","message":"Access Denied","path":"/api/products/import"}Curl Ends!
I checked and there is no IP whitelisting needed on the server.