0

It return just "success1". here is my code and xml file. Please anyone help me why the product is not imported to volusion. When i run this code it just return 1. i don't know what is the problem and product is not inserted.

<Import>
   <Products>
      <ProductID>360</ProductID>
      <productcode>10035</productcode>
      <vendor_partno>035</vendor_partno>
      <productname>Asus Video Card ATI Doulat</productname>
      <listprice>6.95</listprice>
      <productprice>2</productprice>
      <vendor_price>3.83</vendor_price>
      <stockstatus>100</stockstatus>
      <upc_code>99999</upc_code>
      <categoryids>107,134</categoryids>
      <productdescriptionshort />
      <productdescription />
      <productweight>0.00</productweight>
      <freeshippingitem />
      <minqty />
      <maxqty />
   </Products>
</Import>
  1. My Api request code

//  Create the Xml to POST to the Webservice

    $Xml_to_Send = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>";
    $Xml_to_Send .= "<Volusion_API>";
//  $Xml_to_Send .= "<!--";
    $Xml_to_Send .= $file;
//  $Xml_to_Send .= "\"\"";
//  $Xml_to_Send .= "-->";
    $Xml_to_Send .= "</Volusion_API>";

    $url = "http://tebkq.mvlce.servertrust.com/net/WebService.aspxLogin=mylogin&EncryptedPassword=mypassword&Import=Insert";

//  Create the Header   

    $header  = array(
    "MIME-Version: 1.0",
    "Content-type: text/xml; charset=utf-8",
    "Content-transfer-encoding: text",
    "Request-number: 1",
    "Document-type: Request",
    "Interface-Version: Test 1.4"
);

    //  Post and Return Xml
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $Xml_to_Send); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    $data = curl_exec($ch);
     //echo $data;
    //  Check for Errors
    if (curl_errno($ch)){
        echo "error";
        print curl_error($ch);
    } else {
        echo "success";
       curl_close($ch);
    }

   //  Display the Xml Returned on the Browser
    echo $data;
?>
Clay
  • 4,700
  • 3
  • 33
  • 49
Doulat Khan
  • 493
  • 5
  • 24

2 Answers2

0

Remove <Import></Import> and it should work.

user357034
  • 10,731
  • 19
  • 58
  • 72
0

In your xml, try replacing the import node with xmldata:

<?xml version="1.0" encoding="utf-8" ?>
<xmldata>
    <Products>
        <ProductID>360</ProductID>
        .....
    </Products>
</xmldata>

This is what I use for a header when sending inserts or updates

curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/x-www-form-urlencoded; charset=utf-8", "Content-Action:Volusion_API"));
Phil S
  • 179
  • 2