I am developing a android app for SharePoint 2010. i want to update SharePoint 2010 UpdateListItem using below code
private void updateListItem(){
String serviceUrl = "http://demo.com/_vti_bin/Lists.asmx";
HttpClient httpclient = new DefaultHttpClient();
((AbstractHttpClient) httpclient).getAuthSchemes().register("ntlm",
new NTLMSchemeFactory());
NTCredentials creds = new NTCredentials("username", "password", "55",
"demo");
((AbstractHttpClient) httpclient).getCredentialsProvider()
.setCredentials(AuthScope.ANY, creds);
try {
HttpConnectionParams.setConnectionTimeout(httpclient.getParams(),
120000);
HttpPost httppost = new HttpPost(serviceUrl);
StringEntity se;
String str1 ="<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body>"
+ "<UpdateListItems xmlns=\"http://schemas.microsoft.com/sharepoint/soap/\">"
+ "<listName>"
+ "{DF1398C7-EF73-485E-913E-5F5896D6DF22}"
+ "</listName>"
+ "<updates>"
+ "<Batch OnError='Continue' ListVersion='1'>"
+ "<Method ID='1' Cmd='New'>"
+ "<Field Name='Title'>View</Field>"
+ "<Field Name='Resource'>7;#A Kr Singh</Field>"
+ "<Field Name='Project'>13;#Microsoft- SharePoint based Employee Portal</Field>"
+ "<Field Name='Task'>1;#Accounting</Field>"
+ "<Field Name='Date'>2014-11-21 11:15:50</Field>"
+ "</Method>"
+ "</Batch>"
+ "</updates>"
+ "</UpdateListItems>"
+ "</soap:Body>" + "</soap:Envelope>";
se = new StringEntity(String.format(str1, HTTP.UTF_8));
se.setContentType("text/xml");
httppost.setEntity(se);
HttpResponse httpresponse = httpclient.execute(httppost);
InputStream in = httpresponse.getEntity().getContent();
String str = inputStreamToString(in).toString();
readSoap(str);
} catch (Exception e) {
e.printStackTrace();
}
}
But getting error
soap:ServerException of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.The security validation for this page is invalid. Click Back in your Web browser, refresh the page, and try your operation again.0x8102006d
Please give me any solution.. Or give me any other way to update Sharepoint List Item using android..