Publish data on server in android

I want to send some data to the server via the POST method in android. I am using the following code

DefaultHttpClient hc=new DefaultHttpClient();  
ResponseHandler <String> res=new BasicResponseHandler();  
HttpPost postMethod=new HttpPost(url); 
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2); 
nameValuePairs.add(new BasicNameValuePair("name", "value"));     
nameValuePairs.add(new BasicNameValuePair("password", "value"));    
postMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));    
String response=hc.execute(postMethod,res); 

But I get an error response in my xml response. Error message - cookies are disabled on the client computer. How do I need to enable cookies in android?

+3
source share
1 answer

You need to process cookies with your request. See this and this related questions.

+1
source

Source: https://habr.com/ru/post/1772429/


All Articles