Jump to content

This call to PrestaShop Web Services failed and returned an HTTP status of 500


narendra1984ab

Recommended Posts

Hello there,  I am getting following error on live server
 
"This call to PrestaShop Web Services failed and returned an HTTP status of 500".
 
However same code is working fine on localhost and also I have added my modules in many sites and its seems working fine to create order.
 
I have added my created function addOrder in which I observed that the code works fine upto
"  $xml = $webService->add(array(
            'resource' => 'orders?sendmail=1',
            'postXml' => $xml->asXML()
        ));"
 
Its create order in backend but not inserting the order status. I am using current_state to send status id.
I dont know  why its gives  error "This call to PrestaShop Web Services failed and returned an HTTP status of 500".
 
I also enabled the debugger in which I got below error
 
{"error":"Other errorHTTP XML response is not parsable: array (\n  0 => \n  LibXMLError::__set_state(array(\n     'level' => 3,\n     'code' => 4,\n     'column' => 1,\n     'message' => 'Start tag expected, \\'<\\' not found\n',\n     'file' => '',\n     'line' => 2,\n  )),\n)"}
 
Everything is  correct but I dont understood this last error. Can you please go through my function and let me know any solution. Thanks in advance
 
public function addOrder($dataOrderArray)
    {
        $id_address_delivery = $dataOrderArray['order']['id_address_delivery'];
        $id_address_invoice = $dataOrderArray['order']['id_address_invoice'];
        $id_cart = $dataOrderArray['order']['id_cart'];
        $id_currency = $dataOrderArray['order']['id_currency'];
        $id_lang = $dataOrderArray['order']['id_lang'];
        $id_customer = $dataOrderArray['order']['id_customer'];
        $id_carrier = $dataOrderArray['order']['id_carrier'];
        $current_state = $dataOrderArray['order']['current_state'];
        $module = $dataOrderArray['order']['module'];
        $valid = $dataOrderArray['order']['valid'];
        $id_shop_group = $dataOrderArray['order']['id_shop_group'];
        $id_shop = $dataOrderArray['order']['id_shop'];
        $payment = $dataOrderArray['order']['payment'];
        $total_discounts = $dataOrderArray['order']['total_discounts'];
        $total_discounts_tax_incl = $dataOrderArray['order']['total_discounts_tax_incl'];
        $total_discounts_tax_excl = $dataOrderArray['order']['total_discounts_tax_excl'];
        $total_paid = $dataOrderArray['order']['total_paid'];
        $total_paid_tax_incl = $dataOrderArray['order']['total_paid_tax_incl'];
        $total_paid_tax_excl = $dataOrderArray['order']['total_paid_tax_excl'];
        $total_paid_real = $dataOrderArray['order']['total_paid_real'];
        $total_products = $dataOrderArray['order']['total_products'];
        $total_products_wt = $dataOrderArray['order']['total_products_wt'];
        $total_shipping = $dataOrderArray['order']['total_shipping'];
        $total_shipping_tax_incl = $dataOrderArray['order']['total_shipping_tax_incl'];
        $total_shipping_tax_excl = $dataOrderArray['order']['total_shipping_tax_excl'];
        $conversion_rate = $dataOrderArray['order']['conversion_rate'];
        
        $webService = new PrestaShopWebservice(PS_SHOP_PATH, PS_WS_AUTH_KEY, DEBUG);
        $xml = $webService->get(array('url' => PS_SHOP_PATH.'api/orders?schema=blank'));
        $xml->order->id_address_delivery = (int)$id_address_delivery;
        $xml->order->id_address_invoice = (int)$id_address_invoice;
        $xml->order->id_cart = (int)$id_cart;
        $xml->order->id_currency = (int)$id_currency;
        $xml->order->id_lang = (int)$id_lang;
        $xml->order->id_customer = (int)$id_customer;
        $xml->order->id_carrier = (int)$id_carrier;
        $xml->order->current_state = (int)$current_state;
        $xml->order->module = pSQL($module);
        $xml->order->valid = (int)$valid;
        $xml->order->id_shop_group = (int)$id_shop_group;
        $xml->order->id_shop = (int)$id_shop;
        $xml->order->payment = pSQL($payment);
        $xml->order->total_discounts = (float)$total_discounts;
        $xml->order->total_discounts_tax_incl = (float)$total_discounts_tax_incl;
        $xml->order->total_discounts_tax_excl = (float)$total_discounts_tax_excl;
        $xml->order->total_paid = (float)$total_paid;
        $xml->order->total_paid_tax_incl = (float)$total_paid_tax_incl;
        $xml->order->total_paid_tax_excl = (float)$total_paid_tax_excl;
        $xml->order->total_paid_real = (float)$total_paid_real;
        $xml->order->total_products = (float)$total_products;
        $xml->order->total_products_wt = (float)$total_products_wt;
        $xml->order->total_shipping = (float)$total_shipping;
        $xml->order->total_shipping_tax_incl = (float)$total_shipping_tax_incl;
        $xml->order->total_shipping_tax_excl = (float)$total_shipping_tax_excl;
        $xml->order->conversion_rate = (float)$conversion_rate;
        
        $xml = $webService->add(array(
            'resource' => 'orders?sendmail=1',
            'postXml' => $xml->asXML()
        ));
        $result = $xml->children()->children();
        $orderID = $result->{'id'};
        return (int)$orderID[0];
    }

 

Link to comment
Share on other sites

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...