title: PrestaShop - Update a Product using Web-service and t-sql stored procedures / XML
body: <p>I want to update a PrestaShop product using web services from tsql.</p>
  
  <p>I have already the xml variable created in sql.</p>
  
  <p>According to the PrestaShop documentation, I have to:</p>
  
  <blockquote>
    <p>[...] Send POST HTTP request with the whole XML as body content [...]</p>
  </blockquote>
  
  <p>Using Get isn't any problem with oa_mothods from sql, but what is the syntax for POST/PUT any xml variables to Create or Update an existing product?</p>
  
  <pre><code>declare @xmlRIA xml
  
  set @xmlRIA = CAST('&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;prestashop&gt;
      &lt;customer&gt;
          &lt;id&gt;&lt;/id&gt;
          &lt;id_default_group&gt;3&lt;/id_default_group&gt;
          &lt;id_lang&gt;1&lt;/id_lang&gt;
          &lt;newsletter_date_add&gt;0000-00-00 00:00:00&lt;/newsletter_date_add&gt;
          &lt;ip_registration_newsletter&gt;&lt;/ip_registration_newsletter&gt;
          &lt;last_passwd_gen&gt;2017-04-29 05:34:22&lt;/last_passwd_gen&gt;
          &lt;secure_key&gt;&lt;/secure_key&gt;
          &lt;deleted&gt;0&lt;/deleted&gt;
          &lt;passwd&gt;&lt;/passwd&gt;
          &lt;lastname&gt;test&lt;/lastname&gt;
          &lt;firstname&gt;test&lt;/firstname&gt;
          &lt;email&gt;kow@testde.com&lt;/email&gt;
          &lt;id_gender&gt;2&lt;/id_gender&gt;
          &lt;birthday&gt;0000-00-00&lt;/birthday&gt;
          &lt;newsletter&gt;0&lt;/newsletter&gt;
          &lt;optin&gt;0&lt;/optin&gt;
          &lt;website&gt;&lt;/website&gt;
          &lt;company&gt;&lt;/company&gt;
          &lt;siret&gt;&lt;/siret&gt;
          &lt;ape&gt;&lt;/ape&gt;
          &lt;outstanding_allow_amount&gt;0.000000&lt;/outstanding_allow_amount&gt;
          &lt;show_public_prices&gt;0&lt;/show_public_prices&gt;
          &lt;id_risk&gt;0&lt;/id_risk&gt;
          &lt;max_payment_days&gt;0&lt;/max_payment_days&gt;
          &lt;active&gt;1&lt;/active&gt;
          &lt;note&gt;&lt;/note&gt;
          &lt;is_guest&gt;0&lt;/is_guest&gt;
          &lt;id_shop&gt;1&lt;/id_shop&gt;
          &lt;id_shop_group&gt;1&lt;/id_shop_group&gt;
          &lt;date_add&gt;2017-04-29 11:34:22&lt;/date_add&gt;
          &lt;date_upd&gt;2017-04-29 11:34:22&lt;/date_upd&gt;
          &lt;reset_password_token&gt;&lt;/reset_password_token&gt;
          &lt;reset_password_validity&gt;0000-00-00 00:00:00&lt;/reset_password_validity&gt;
          &lt;associations&gt;
              &lt;groups&gt;
                  &lt;group&gt;
                      &lt;id&gt;3&lt;/id&gt;
                  &lt;/group&gt;
              &lt;/groups&gt;
          &lt;/associations&gt;
      &lt;/customer&gt;
  &lt;/prestashop&gt;
   'as XML)
  
  
  
  
  
  
  -- Open a connection
  EXEC @ret = sp_OACreate 'MSXML2.ServerXMLHTTP', @token OUT;
  if @ret &lt;&gt; 0 begin set @MessageError = 'sp_OACreate MSXML2.ServerXMLHttp.3.0 failed' goto final end
  
  EXEC @ret = sp_OAMethod @token, 'open', NULL, 'POST', @url, 'false';
  if @ret &lt;&gt; 0 begin set @MessageError = 'sp_OACreate open' goto final end
  
  EXEC @ret = sp_OAMethod @token, 'setRequestHeader', NULL, 'Authentication', @authHeader;
  if @ret &lt;&gt; 0 begin set @MessageError = 'sp_OACreate Authentication failed' goto final end
  
  EXEC @ret = sp_OAMethod @token, 'setRequestHeader', NULL, 'Content-type', @contentType;
  if @ret &lt;&gt; 0 begin set @MessageError = 'sp_OACreate Content-type failed' goto final end
  
  EXEC @ret = sp_OAMethod @token, 'send', NULL, '';
  if @ret &lt;&gt; 0 begin set @MessageError = 'sp_OAMethod send failed' goto final end
  
  -- Handle response
  EXEC @ret = sp_OAGetProperty @token, 'status', @status OUT;
  if @ret &lt;&gt; 0 begin set @MessageError = 'sp_OAGetProperty status' goto final end
  
  EXEC @ret = sp_OAGetProperty @token, 'statusText', @statusText OUT;
  if @ret &lt;&gt; 0 begin set @MessageError = 'sp_OAGetProperty statusText failed' goto final end
  
  
  EXEC @ret = sp_OAMethod @token, 'send', NULL, @xmlria
  IF @ret &lt;&gt; 0 RAISERROR('sp_OAMethod SEND 2 failed.', 10, 1);
  </code></pre>