I'm trying to submit some data in SP2013 (using listdata.svc) from my WP client app. The code, as shown below runs perfectly fine in console app, but doesn't work on device.
MyDataContext context = new MyDataContext(new Uri("http://SP2013/_vti_bin/listdata.svc")); context.Credentials = new NetworkCredential(@"domain\username", "password"); var item = Item.CreateItem(160); item.Feedback = new Value(); item.Feedback.Value = "12345"; item.EmailID = "12345"; item.RegistrationNumber = "12345"; item.Title = "12345"; try { context.AddToFeedback(item); context.BeginSaveChanges(SaveChangesOptions.Batch, SaveChangesCallback, context); } catch (Exception ex) { throw; } private static void SaveChangesCallback(IAsyncResult asynchronousResult) { var context = asynchronousResult.AsyncState as NZ2013DataContext; if (context != null) { var res = context.EndSaveChanges(asynchronousResult); } if (asynchronousResult.IsCompleted) { //do nothing } Console.ReadLine(); }
This code basically throws an exception at EndSaveChanges() on device saying: NotFound details are: BatchStatusCode: 404 StackTrace:
at System.Data.Services.Client.BaseSaveResult.HandleResponse(RequestInfo requestInfo, HttpStatusCode statusCode, String responseVersion, Func`1 getResponseStream, Boolean throwOnFailure, Version& parsedResponseVersion) at System.Data.Services.Client.BatchSaveResult.HandleBatchResponse()
Mayur Tendulkar | http://blog.mayurtendulkar.com