utpal_insync Posted August 8, 2013 Share Posted August 8, 2013 Hi All, I am new to the PrestaShop development and I am developing an application using C# which will interact with the PrestaShop website through webservices. I have created the customer successfully but when I have tried to update the customer using the 'PUT' method it is giving the error The remote server returned an error: (500) Internal Server Error HttpWebRequest request = (HttpWebRequest)WebRequest.Create(http://mysite.com/de...p/api/customers); NetworkCredential nc = new NetworkCredential("8MMSYQ2VJIIJZKRLAVVRD50RHLP6TQSJ", ""); request.Credentials = nc; request.Method = "PUT"; request.ContentType = "application/xml"; string str= " <customer> <id>3</id> <id_default_group xlink:href="http://templatebar.com/dev/prestashop/prestashop/api/languages/1">1</id_lang> <newsletter_date_add>0000-00-00 00:00:00</newsletter_date_add> <ip_registration_newsletter> </ip_registration_newsletter> <deleted>0</deleted> <secure_key>381ae8a5ca84102fbdd98221495ac8ec</secure_key> <passwd>abcd.1234</passwd> <lastname>SAM</lastname> <firstname>Ghosh</firstname> <email>[email protected]</email> <active>1</active> <id_gender>0</id_gender> <birthday>0000-00-00</birthday> <newsletter>0</newsletter> <optin>0</optin> <website> </website> <company> </company> <siret> </siret> <ape> </ape> <outstanding_allow_amount>0.000000</outstanding_allow_amount> <show_public_prices>0</show_public_prices> <id_risk>0</id_risk> <max_payment_days>0</max_payment_days> <active>0</active> <note> </note> <is_guest>0</is_guest> <id_shop>1</id_shop> <id_shop_group>1</id_shop_group> <associations> <groups node_type="group"> <group> <id>3</id> </group> </groups> </associations> </customer> "; byte[] byteArray = Encoding.UTF8.GetBytes("xml=" +str); request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); dataStream.Write(byteArray, 0, byteArray.Length); dataStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (request.HaveResponse) { using (Stream streamContenido = response.GetResponseStream()) { MessageBox.Show(new StreamReader(streamContenido).ReadToEnd()); } } response.Close(); Please rectify if I have made any mistake. Thanks and Regards Utpal Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now