• 10-11-2020, 17:41:50
    #1
    <?php
    
    $url = "https://mpop-sit.hepsiburada.com/product/api/products/import";
    
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
    
    $headers = array(
       "Accept: application/json",
       "Content-Type: multipart/form-data",
       "Authorization: Bearer {TOKENİM}",
    );
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
    
    $data = '
    {
        "categoryId": 18021982,
        "merchant": "6fc6d90d-ee1d-4372-b3a6-264b1275e9ff",
        "attributes": {
          "merchantSku": "SAMPLE-SKU-INT-0",
           "VaryantGroupID": "Hepsiburada0",
          "Barcode": "1234567891234",
          "UrunAdi": "Roth Tyler",
          "UrunAciklamasi": "Duis enim duis magna ex veniam elit id Lorem cillum minim nisi id aliquip. Laboris magna id est et deserunt adipisicing tempor eu ea officia ipsum deserunt. Irure occaecat sit aliquip elit ipsum sint dolore quis est amet aute pariatur cupidatat fugiat. Cillum pariatur pariatur occaecat sint. Aliqua qui in exercitation nulla aliquip id ipsum aliquip ad ut excepteur culpa consequat aliquip. Nisi ut ex tempor enim adipisicing anim irure pariatur.rn",
          "Marka": "Nike",
          "GarantiSuresi": 24,
          "kg": "1",
          "tax_vat_rate" : "5",
          "Image1": "https://productimages.hepsiburada.net/s/27/552/10194862145586.jpg",
          "Image2": "https://productimages.hepsiburada.net/s/27/552/10194862145586.jpg",
          "Image3": "https://productimages.hepsiburada.net/s/27/552/10194862145586.jpg",
          "Image4": "https://productimages.hepsiburada.net/s/27/552/10194862145586.jpg",
          "Image5": "https://productimages.hepsiburada.net/s/27/552/10194862145586.jpg",
          "renk_variant_property": "Siyah",
          "ebatlar_variant_property": "Büyük Ebat"
        }
      }
    ';
    
    curl_setopt($curl, CURLOPT_POSTFIELDS,file_get_contents("data.json"));
    
    //for debug only!
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    
    $resp = curl_exec($curl);
    curl_close($curl);
    var_dump($resp);
    
    ?>
    {"success":false,"code":3003,"version":1,"message" :"File not found","data":null}

    çıktı olarak ise bu hatayı veriyor ne yaptıysam olmadı sebebi nedir yardım edebilecek varmı
  • 03-05-2021, 14:41:46
    #2
    Merhabalar,
    Çözebildiniz mi problemi ?
    Şuanda aynısını yaşıyorum.
  • 03-05-2021, 17:40:26
    #3
    Data.json ı algılayamıyor gibi görünüyor
    include "data.json"; yaparmısınız dosyayı alabiliyorsunuz dosya yolu doğrudur alamıyorsanız doğru dosya yolunu vermelisiniz
  • 03-05-2021, 18:07:56
    #4
    WRaNGLeR adlı üyeden alıntı: mesajı görüntüle
    Data.json ı algılayamıyor gibi görünüyor
    include "data.json"; yaparmısınız dosyayı alabiliyorsunuz dosya yolu doğrudur alamıyorsanız doğru dosya yolunu vermelisiniz
    Cevap için teşekkür.
    Postmanden denedim select file ile sectim olmadı text yaptım.
    Link verdim https://www.kidspartim.com/uploads/test.json olmadı.
    Ama ben misal tekrar $data değişkenini olusturmadım.
    Zaten dosyanın içinde verdiğim için.

    https://developers.hepsiburada.com/?...n-dosyas%C4%B1

    biyerde bişeyimi kacırıorm anlamadm.
  • 03-05-2021, 20:47:17
    #5
    <?php
     
    $file_path = "a.json";
    $real_path = realpath($file_path);
    
    $url = "https://mpop-sit.hepsiburada.com/product/api/products/import";
     
    $curl = curl_init($url);
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_POST, true);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     
    $headers = array(
       "Accept: application/json",
       "Content-Type: multipart/form-data",
       "Authorization: Bearer {TOKENİM}",
    );
    	
    $fields_for_file = [
    				'filename' => new CurlFile($real_path, mime_content_type($real_path), basename($real_path))
    
    			];
    			
    curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     
    curl_setopt($curl, CURLOPT_POSTFIELDS, $fields_for_file); 
    
    
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
     
    $resp = curl_exec($curl);
    curl_close($curl);
    var_dump($resp);
     
    ?>
    Bu şekilde dener misiniz
  • 11-09-2021, 16:44:08
    #6
    Bende aynı sorunu yaşıyorum ve bir türlü çözemedim. Siz çözebildiniz mi acaba?
  • 11-09-2021, 17:24:01
    #7
    kraldorukkosar adlı üyeden alıntı: mesajı görüntüle
    Bende aynı sorunu yaşıyorum ve bir türlü çözemedim. Siz çözebildiniz mi acaba?
    Sorunu çözdüm arkadaşlar.. Bizden sonra takılan olursa diye çalışan kodu aşağıda gönderiyorum.

    $cf = new CURLFile('product.json');
    
        $data_file = array('file' => $cf);
    
        $ch = curl_init('https://mpop-sit.hepsiburada.com/product/api/products/import');
        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic '.base64_encode($auth['base64_test']), 'Accept: application/json','Content-Type: multipart/form-data'));
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data_file);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    
        $product = curl_exec($ch);
        curl_close($ch);