Jump to content

Difficulty using web service : error when adding tracking number


taophp

Recommended Posts

Hello everybody,

 

i'm trying to use the PrestaShop web service to update the tracking number of an order. Doing, an error occurs that I do not understand.

 

First, I get all order_carriers associations :

 

Request:

GET http://myshop.com/api/order_carriers

Answer:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop
    xmlns:xlink="http://www.w3.org/1999/xlink">
    <order_carriers>
        <order_carrier id="1" xlink:href="http://myshop.com/api/order_carriers/1"/>
        <order_carrier id="2" xlink:href="http://myshop.com/api/order_carriers/2"/>
[...]
        <order_carrier id="41" xlink:href="http://myshop.com/api/order_carriers/41"/>
        <order_carrier id="42" xlink:href="http://myshop.com/api/order_carriers/42"/>
    </order_carriers>
</prestashop>

I display informations about the last.

Request:

GET http://myshop.com/api/order_carriers/42

Answer:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop
    xmlns:xlink="http://www.w3.org/1999/xlink">
    <order_carrier>
        <id>
            <![CDATA[42]]>
        </id>
        <id_order xlink:href="http://myshop.com/api/orders/120">
            <![CDATA[120]]>
        </id_order>
        <id_carrier xlink:href="http://myshop.com/api/carriers/1">
            <![CDATA[1]]>
        </id_carrier>
        <id_order_invoice>
            <![CDATA[20]]>
        </id_order_invoice>
        <weight>
            <![CDATA[0.000000]]>
        </weight>
        <shipping_cost_tax_excl>
            <![CDATA[0.000000]]>
        </shipping_cost_tax_excl>
        <shipping_cost_tax_incl>
            <![CDATA[0.000000]]>
        </shipping_cost_tax_incl>
        <tracking_number></tracking_number>
        <date_add>
            <![CDATA[2017-09-25 11:04:00]]>
        </date_add>
    </order_carrier>
</prestashop>

I try to update using the same informations but the tracking number.

Request :

PUT http://myshop.com/api/order_carriers/42
<?xml version="1.0" encoding="UTF-8"?>
<prestashop
    xmlns:xlink="http://www.w3.org/1999/xlink">
    <order_carrier>
        <id>
            <![CDATA[42]]>
        </id>
        <id_order xlink:href="http://myshop.com/api/orders/120">
            <![CDATA[120]]>
        </id_order>
        <id_carrier xlink:href="http://myshop.com/api/carriers/1">
            <![CDATA[1]]>
        </id_carrier>
        <id_order_invoice>
            <![CDATA[20]]>
        </id_order_invoice>
        <weight>
            <![CDATA[0.000000]]>
        </weight>
        <shipping_cost_tax_excl>
            <![CDATA[0.000000]]>
        </shipping_cost_tax_excl>
        <shipping_cost_tax_incl>
            <![CDATA[0.000000]]>
        </shipping_cost_tax_incl>
        <tracking_number>123</tracking_number>
        <date_add>
            <![CDATA[2017-09-25 11:04:00]]>
        </date_add>
    </order_carrier>
</prestashop>

Answer:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop
    xmlns:xlink="http://www.w3.org/1999/xlink">
    <errors>
        <error>
            <code>
                <![CDATA[85]]>
            </code>
            <message>
                <![CDATA[Validation error: "Property OrderCarrier->id_order is not valid"]]>
            </message>
        </error>
    </errors>
</prestashop>

It seems that my id_order in not valid. But I did not change this information, and I've checked that order with this id exists.

Requête:

GET http://aw03.abw.lan/api/orders/120

Answer:

<?xml version="1.0" encoding="UTF-8"?>
<prestashop
    xmlns:xlink="http://www.w3.org/1999/xlink">
    <order>
        <id>
            <![CDATA[120]]>
        </id>
[...]
        <id_carrier xlink:href="http://myshop.com/api/carriers/1">
            <![CDATA[1]]>
        </id_carrier>
        <current_state xlink:href="http://myshop.com/api/order_states/2">
            <![CDATA[2]]>
        </current_state>
[...]
        <invoice_number>
            <![CDATA[20]]>
        </invoice_number>
        <invoice_date>
            <![CDATA[2017-09-25 11:49:42]]>
        </invoice_date>
        <delivery_number>
            <![CDATA[0]]>
        </delivery_number>
        <delivery_date>
            <![CDATA[0000-00-00 00:00:00]]>
        </delivery_date>
        <valid>
            <![CDATA[1]]>
        </valid>
        <date_add>
            <![CDATA[2017-09-25 11:04:00]]>
        </date_add>
        <date_upd>
            <![CDATA[2017-09-25 11:49:51]]>
        </date_upd>
        <shipping_number notFilterable="true"></shipping_number>
[...]        <reference>
            <![CDATA[FZRUHKGDF]]>
        </reference>
[...]
    </order>
</prestashop>

On the other side, I have no error, including in the web server log.

 

Can anyone help to solve this issue ?

 

Regards,

 

Taophp

 

 

 

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