Jump to content

WebService | New Order XML Error (Response is not parsable)


JTDVNT

Recommended Posts

Hello there,

 

I am trying to dynamically create an order through PrestaShop's webservice.

First I create a customer, then address, then cart and finally an order.

 

However, an error that I get when trying to create a new order, looks like this:

 

HTTP XML response is not parsable: array (
  0 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 9,
     'column' => 65,
     'message' => 'Input is not proper UTF-8, indicate encoding ! Bytes: 0x98 0x1F 0x55 0x11',
     'file' => '',
     'line' => 779,
  )),
  1 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 9,
     'column' => 66,
     'message' => 'PCDATA invalid Char value 31',
     'file' => '',
     'line' => 779,
  )),
  2 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 9,
     'column' => 68,
     'message' => 'PCDATA invalid Char value 17',
     'file' => '',
     'line' => 779,
  )),
  3 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 9,
     'column' => 71,
     'message' => 'PCDATA invalid Char value 29',
     'file' => '',
     'line' => 779,
  )),
  4 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 9,
     'column' => 76,
     'message' => 'PCDATA invalid Char value 11',
     'file' => '',
     'line' => 779,
  )),
  5 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 64,
     'column' => 51,
     'message' => 'XML declaration allowed only at the start of the document',
     'file' => '',
     'line' => 13997,
  )),
  6 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 64,
     'column' => 51,
     'message' => 'XML declaration allowed only at the start of the document',
     'file' => '',
     'line' => 16440,
  )),
  7 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 64,
     'column' => 51,
     'message' => 'XML declaration allowed only at the start of the document',
     'file' => '',
     'line' => 18882,
  )),
  8 =>
  LibXMLError::__set_state(array(
     'level' => 3,
     'code' => 64,
     'column' => 33,
     'message' => 'XML declaration allowed only at the start of the document',
     'file' => '',
     'line' => 19494,
  )),
)

Here's the code I am using:

 

$xml_order = $webService->get(array('url' => $basepath . '/api/orders?schema=blank'));

$xml_order->children()->children()->conversion_rate = 1;
$xml_order->children()->children()->date_add = date('Y-m-d H:i:s');
$xml_order->children()->children()->id_address_delivery = (int) $delivery_address_id;
$xml_order->children()->children()->id_address_invoice = (!is_null($billing_address_id)) ? (int) $billing_address_id : (int) $delivery_address_id;
$xml_order->children()->children()->id_carrier = 0;
$xml_order->children()->children()->id_cart = (int) $cart_id;
$xml_order->children()->children()->id_currency = (int) $this->context->currency->id;
$xml_order->children()->children()->id_customer = (int) $customer_id;
$xml_order->children()->children()->id_lang = (int) $this->context->language->id;
$xml_order->children()->children()->id_shop = (int) $this->context->shop->id;
$xml_order->children()->children()->module = 'bankwire';
$xml_order->children()->children()->payment = 'Bank wire';
$xml_order->children()->children()->total_paid = Tools::getValue('total_products');
$xml_order->children()->children()->total_paid_real = Tools::getValue('total_products');
$xml_order->children()->children()->total_paid_tax_excl = Tools::getValue('total_products');
$xml_order->children()->children()->total_paid_tax_incl = Tools::getValue('total_products_wt');
$xml_order->children()->children()->total_products = Tools::getValue('total_products');
$xml_order->children()->children()->total_products_wt = Tools::getValue('total_products_wt');
$xml_order->children()->children()->valid = 1;

$xml = $webService->add(array(
    'resource' => 'orders',
    'postXml' => $xml_order->asXML()
));

$resources = $xml->children()->children();
$order_id = $resources->id;

At the moment I have no idea what's causing this error to occur.. Could someone help me with this?

Link to comment
Share on other sites

  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...