Salman Zafar Salman Zafar - 1 year ago 70
PHP Question

How to create new categories in Volusion using Volusion API

Actually I have a store and importing products and categories both from my vendor store to my store, the products are inserted and updated successfully but the categories are not inserted and updated.

I want to create/add new category through API.

My category.txt file.

<?xml version="1.0"?>

Here is my cURL script of Importing.

$file = file_get_contents('category.txt', true);

// 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://mysitedomian/net/WebService.aspx?Login=xxxxxxxxxxx&EncryptedPassword=xxxxxxxxx&Import=Insert-Update";

// Create the Header

// 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, array("Content-Type:application/x-www-form-urlencoded; charset=utf-8", "Content-Action:Volusion_API"));
$data = curl_exec($ch);

// Check for Errors
if (curl_errno($ch)){

print curl_error($ch);
} else {


// Display the Xml Returned on the Browser

echo $data;


Answer Source

Just remove the following from your category.txt this

<?xml version="1.0"?>

Because it is already defined in your cURL script, and Volusion API not support double defined tags.

Remove the above and pass to your cURL script and run the cURL script it will work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download