Я хочу обновить данные через веб-сервис в Android. выполнение операции POST для того же самого, но при выполнении «httpClient.execute(httppost)
» оно ловит исключение, и сообщение об исключении равно NULL
Любой, пожалуйста, помогите мне!
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("https://myurl");
try {
String xmln = XMLfunctions.getXMLn();
String Authorization= "Basic usrnameandpasswrd";
httppost.setHeader("Accept", "text/xml");
httppost.setHeader("Authorization", Authorization);
httppost.setHeader("Content-Type", "text/xml;charset=utf-8");
int ln=xmln.length();
String sln="";
sln=sln+ln;
httppost.setHeader("Content-Length", sln);
//Add your data
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("UserID", "0085b488"));
nameValuePairs.add(new BasicNameValuePair("FName", "Prasanth"));
nameValuePairs.add(new BasicNameValuePair("LName", "san"));
nameValuePairs.add(new BasicNameValuePair("Email", "prasanth.raghavan@xyz.com"));
nameValuePairs.add(new BasicNameValuePair("Image", "image encryptdAAAAASUVORK5CYII="));
nameValuePairs.add(new BasicNameValuePair("Culture", "en_IN"));
nameValuePairs.add(new BasicNameValuePair("Timezone", "5.0000"));
nameValuePairs.add(new BasicNameValuePair("DaylightSavings", "false"));
nameValuePairs.add(new BasicNameValuePair("PhoneNumber", "9999999999"));
StringEntity entity = new StringEntity(nameValuePairs.toString(), "UTF-8");
httppost.setEntity(entity);
BasicHttpResponse responseGet =(BasicHttpResponse) httpClient.execute(httppost);
//tried this too
//HttpResponse responseGet = httpClient.execute(httppost);
// Execute HTTP Post Request
// not executing HttpEntity httpEntity = responseGet.getEntity();
// not executing String line = EntityUtils.toString(httpEntity);
} catch (ClientProtocolException e) {
String err=e.getMessage(); // err = NULL Here
}
catch (IOException e)
{ // TODO Auto-generated catch block }