Search the Community
Showing results for tags 'prestashit'.
-
No consigo conectar con prestashop desde sql server y recoger productos, he puesto en la url el token con la tienda y el chrome funciona correctamente pero desde sql server las respuestas son: {"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"} o 401 Unauthorized He probado con también con user y password pero el resultado es el mismo, adjunto código, alguien puede indicarme que falta. declare @username varchar (200) = 'user' declare @password varchar (200) = 'password' declare @obj int declare @sUrl varchar (200) declare @response varchar (8000) declare @hr int declare @status INT declare @statusText VARCHAR (200) declare @source varbinary (max), @encoded_base64 varchar (max), @auth varchar (max) SET @source = CONVERT (varbinary (max), @username + ':' + @password) --- Convertir de varbinary a cadena base64 SET @encoded_base64 = CAST( CAST( @source as XML ).value('.','varbinary(max)') AS varchar(max) ) set @sUrl = 'http://xxxxxxxxxxxxxxxxxxxxxxxxxtokenxxxxxxxxxxxxxxxxxxxxxx@tiendaonline.cat/api/products' SET @auth = 'Básico ' + @encoded_base64 exec @hr = sp_OACreate 'MSXML2.ServerXMLhttp', @obj out exec @hr = sp_OAMethod @obj, 'setRequestHeader', null, 'Authorization', @auth exec sp_OAMethod @obj, 'setRequestHeader', null, 'Accept', 'application/json' exec @hr = sp_OAMethod @obj, 'Open', null, 'GET', @sUrl, false exec sp_OAMethod @obj, 'send', null, @auth exec sp_OAgetproperty @obj, 'responseText', @response out exec sp_OAgetproperty @obj, 'status', @status out exec sp_OAgetproperty @obj, 'StatusText', @statusText out exec sp_OADestroy @obj select @status [StatusCode], @statusText [StatusText], @response [Respuesta]
-
Hi ! I want to create an order on my shops with the API, so at first I create a card with the following call : POST mypresta.com/api/carts?ws_key=my_key body: <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <cart> <id_currency><![CDATA[1]]></id_currency> <id_lang><![CDATA[1]]></id_lang> <associations> <cart_rows nodeType="cart_row" virtualEntity="true"> <order_row> <id_product><![CDATA[1]]></id_product> <id_product_attribute><![CDATA[1]]></id_product_attribute> <quantity><![CDATA[5]]></quantity> <id_address_delivery><![CDATA[1]]></id_address_delivery> </order_row> <order_row> <id_product><![CDATA[2]]></id_product> <id_product_attribute><![CDATA[2]]></id_product_attribute> <quantity><![CDATA[4]]></quantity> <id_address_delivery><![CDATA[1]]></id_address_delivery> </order_row> </cart_rows> </associations> </cart> </prestashop> and then, with the generated card, i want to create my order with a second call : POST mypresta.com/api/orders?ws_key=my_key body: <?xml version="1.0" encoding="UTF-8"?> <prestashop> <order> <id_address_delivery><![CDATA[1]]></id_address_delivery> <id_address_invoice><![CDATA[1]]></id_address_invoice> <id_cart><![CDATA[9]]></id_cart> <id_currency><![CDATA[1]]></id_currency> <id_lang><![CDATA[1]]></id_lang> <id_customer><![CDATA[1]]></id_customer> <id_carrier><![CDATA[2]]></id_carrier> <current_state><![CDATA[2]]></current_state> <module><![CDATA[cheque]]></module> <payment><![CDATA[Payment by check]]></payment> <total_paid><![CDATA[45]]></total_paid> <total_paid_real><![CDATA[45]]></total_paid_real> <total_products><![CDATA[2]]></total_products> <total_products_wt><![CDATA[2]]></total_products_wt> <conversion_rate><![CDATA[1]]></conversion_rate> <associations> <order_rows nodeType="order_row" virtualEntity="true"> <order_row> <product_id><![CDATA[1]]></product_id> <product_attribute_id><![CDATA[1]]></product_attribute_id> <product_quantity><![CDATA[5]]></product_quantity> </order_row> <order_row> <product_id><![CDATA[2]]></product_id> <product_attribute_id><![CDATA[2]]></product_attribute_id> <product_quantity><![CDATA[4]]></product_quantity> </order_row> </order_rows> </associations> </order> </prestashop> on this second call i got a response with the http code 200 and the following raw text: FATAL ERROR How can i create order on my shops from the webservices ? PS: presta version 1.5 or 1.6 or 1.7 (got the same error on all those versions)