Jump to content

.Net Webservice update orders


ondio

Recommended Posts

Hi,

 

I am developping a Windows service Application in C#.NET that gets and updates informations from prestashop.

 

I can get all the informations but

I have a problem when  i try to update orders.

the error is the error 405.

 

the peace of code is the folowing :

            var response = Fonctions.GetXML(Url + "orders/950", Key);
            string xms = response.ToString();
   

            byte[] byteArray = Encoding.UTF8.GetBytes(xms);
            WebRequest Req1 = WebRequest.Create(Url + "orders/950" );
            Req1.Method = "PUT";
            Req1.Credentials = new NetworkCredential(Key, "");
            Req1.ContentLength = byteArray.Length;
            Stream postStream = null;
            postStream = Req1.GetRequestStream();
                postStream.Write(byteArray, 0, byteArray.Length);
            postStream.Close();
            HttpWebResponse Resp1 = (HttpWebResponse)Req1.GetResponse();

 

 

 

The xml is the folowing:

 

<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
  <order>
    <id><![CDATA[950]]></id>
    <id_address_delivery xlink:href="http://localhost/api/addresses/675"><![CDATA[675]]></id_address_delivery>
    <id_address_invoice xlink:href="http://localhost/api/addresses/675"><![CDATA[675]]></id_address_invoice>
    <id_cart xlink:href="http://localhost/api/carts/3911"><![CDATA[3911]]></id_cart>
    <id_currency xlink:href="http://localhost/api/currencies/1"><![CDATA[1]]></id_currency>
    <id_lang xlink:href="http://localhost/api/languages/1"><![CDATA[1]]></id_lang>
    <id_customer xlink:href="http://localhost/api/customers/677"><![CDATA[677]]></id_customer>
    <id_carrier xlink:href="http://localhost/api/carriers/103"><![CDATA[103]]></id_carrier>
    <current_state xlink:href="http://localhost/api/order_states/3"><![CDATA[3]]></current_state>
    <module><![CDATA[atos]]></module>
    <invoice_number><![CDATA[777]]></invoice_number>
    <invoice_date><![CDATA[2014-06-04 17:32:05]]></invoice_date>
    <delivery_number><![CDATA[0]]></delivery_number>
    <delivery_date><![CDATA[0000-00-00 00:00:00]]></delivery_date>
    <valid><![CDATA[1]]></valid>
    <id_shop_group><![CDATA[1]]></id_shop_group>
    <id_shop><![CDATA[1]]></id_shop>
    <payment><![CDATA[Atos]]></payment>
    <recyclable><![CDATA[0]]></recyclable>
    <gift><![CDATA[0]]></gift>
    <gift_message></gift_message>
    <mobile_theme><![CDATA[0]]></mobile_theme>
    <total_discounts><![CDATA[0.00]]></total_discounts>
    <total_discounts_tax_incl><![CDATA[0.00]]></total_discounts_tax_incl>
    <total_discounts_tax_excl><![CDATA[0.00]]></total_discounts_tax_excl>
    <total_paid><![CDATA[21.50]]></total_paid>
    <total_paid_tax_incl><![CDATA[21.50]]></total_paid_tax_incl>
    <total_paid_tax_excl><![CDATA[19.00]]></total_paid_tax_excl>
    <total_paid_real><![CDATA[21.50]]></total_paid_real>
    <total_products><![CDATA[12.50]]></total_products>
    <total_products_wt><![CDATA[15.00]]></total_products_wt>
    <total_shipping><![CDATA[6.50]]></total_shipping>
    <total_shipping_tax_incl><![CDATA[6.50]]></total_shipping_tax_incl>
    <total_shipping_tax_excl><![CDATA[6.50]]></total_shipping_tax_excl>
    <carrier_tax_rate><![CDATA[0.000]]></carrier_tax_rate>
    <total_wrapping><![CDATA[0.00]]></total_wrapping>
    <total_wrapping_tax_incl><![CDATA[0.00]]></total_wrapping_tax_incl>
    <total_wrapping_tax_excl><![CDATA[0.00]]></total_wrapping_tax_excl>
    <shipping_number></shipping_number>
    <conversion_rate><![CDATA[1.000000]]></conversion_rate>
    <reference><![CDATA[HODHRCVLD]]></reference>
    <associations>
      <order_rows virtual_entity="true" node_type="order_row">
        <order_row>
          <id><![CDATA[1719]]></id>
          <product_id><![CDATA[36]]></product_id>
          <product_attribute_id><![CDATA[54]]></product_attribute_id>
          <product_quantity><![CDATA[1]]></product_quantity>
          <product_name><![CDATA[Product Name]]></product_name>
          <product_price><![CDATA[12.500000]]></product_price>
          <unit_price_tax_incl><![CDATA[15.000000]]></unit_price_tax_incl>
          <unit_price_tax_excl><![CDATA[12.500000]]></unit_price_tax_excl>
        </order_row>
      </order_rows>
    </associations>

  </order>
</prestashop>

 

 

Can you help me? Sorry my english.

 

I am using Prestashop 1.5.6.2
 

Edited by ondio (see edit history)
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...