mor Posted March 9, 2012 Share Posted March 9, 2012 I want to use vb.net webservice to update the prices of products. to get the current price of the product I use the following code with sucess: Private Sub PrestashopGet(ByVal URL As String, ByVal PWD As String) Try Dim Request As WebRequest = WebRequest.Create(URL & "/products/?display=[price]&filter[id]=[10047]") Request.Method = "GET" Request.Credentials = New NetworkCredential(PWD, "") Dim AnswerString As String Dim Answer As HttpWebResponse = CType(Request.GetResponse(), HttpWebResponse) If Answer.StatusCode = HttpStatusCode.OK Then Dim dataStream As Stream = Answer.GetResponseStream() Dim reader As New StreamReader(dataStream) AnswerString = reader.ReadToEnd() MsgBox(AnswerString) reader.Close() dataStream.Close() End If Answer.Close() Catch MsgBox(Err.Number & vbCrLf & Err.Description) End Try End Sub the answer i get is: <?xml version="1.0" encoding="UTF-8"?> <prestashop xmlns:xlink="http://www.w3.org/1999/xlink"> <products> <product> <price><![CDATA[2.51]]></price> </product> </products> </prestashop> how can I change the price using PUT ? Can anyone help me with a sample code? Link to comment Share on other sites More sharing options...
symphonyx Posted May 16, 2012 Share Posted May 16, 2012 Hello, to change the price you have first to get the product full XML by calling `www.youdomain.com/api/products/{product's id}' Then change the xml tag price you wanna update. Then request, with a PUT HTML method, the updated xml to the same url you resquested you product by get method. In VB I don't know how it works but don't seems to be difficult to manage XML and attach a xml file to your request. Regards Link to comment Share on other sites More sharing options...
Recommended Posts