When my code syncs to the Azure Service I am getting lots of 412 errors
WARNING
Status=412 (PreconditionFailed), Exception=System.Web.Http.HttpResponseException: Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.
I have a mobile service with a Xamarin client. It uses the MobileService SqlLite back end on the client.
Because EntityData class used by Azure Mobile Services is not supported by PCL classes I use the following base class
public class AzureClass { public string Id { get; set; } [Microsoft.WindowsAzure.MobileServices.UpdatedAt] public DateTimeOffset? UpdatedAt { get; set; } [Microsoft.WindowsAzure.MobileServices.Version] public string Version { get; set; } }
One thing I have noticed - is that dispite defining the system fields above, often the update call (Which I have been logging) does not have an UpdatedAt Field.
The calls to sync my data are made like this:
var stepFilter = _stepTbl.CreateQuery().Where(x => x.UserId == member.UserId); await _stepTbl.PullAsync(String.Format("Repo.steps-{0}", member.UserId), stepFilter);
But then the 412 Errors appear in the mobile service logs.
Has anyone had issues with getting these errors in the service?
This is the output from my Service Logging.
Message='+++ Error updating item: StepCount 95(95), Step Date 7/15/2015 12:00:00 AM(7/15/2015 12:00:00 AM), User id a0b49925-b3de-4cdf-84c2-a806ee4d987f, Version Is Null False,UpdateAt (7/15/2015 9:43:15 AM); Version [������iU](������iU)', Status=412 (PreconditionFailed), Exception=System.Web.Http.HttpResponseException: Processing of the HTTP request resulted in an exception. Please see the HTTP response returned by the 'Response' property of this exception for details.
Any values in () are the old values - with the values before them being the new values to be updated. If you look at the UpdatedAt (underlined) output, there is no value before the bracketed value - as this was null.
Tearing my hair out with this one so any help or ideas really appreciated!
Thanks Ash... :-)