What MobileServicePushFailedException error am I getting? How do I read those?

Hey all,

I am working on an Android Xamarin Forms App that is using Azure for its back end. I have all the offline stuff working but I can not PushAsync or PullAsync. I am catching the MobileServicePushFailedExceptions (not sure why I only catch these, I just saw it somewhere), but I don't know how to read it and figure out what the exceptions are.

I found this piece of code and tried it

var errorString = string.Format("Push failed because of sync errors:
{0} errors, message: {1}", ex.PushResult.Errors.Count, ex.Message);
Debug.WriteLine(errorString + " - " + ex.PushResult.Status);
This is what I get back

[0:] Push failed because of sync errors: 2 errors, message: Push operation has failed. See the PushResult for details. - Complete

This is not really helping all that much. So then I created a foreach to run through the errors individually.

And ran this code

Debug.WriteLine("Just error: " + error);
Debug.WriteLine("Just error.RawResult: " + error.RawResult);
Debug.WriteLine("Just error.OperationKind: " + error.OperationKind);
[0:] Just error: Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceTableOperationError
[0:] Just error.RawResult: {"message":"The request is invalid.","modelState":{"item.userId":["An error has occurred."]}}
[0:] Just error.OperationKind: Insert

I get that back twice. And sometimes the number of errors change. But the readouts are ALWAYS the same.

Thanks for any info you all give

Best Answer

  • JohnButlerJohnButler US ✭✭
    Accepted Answer

    I finally figured it out!!!! Oh man.. that was over a week set back :disappointed:

    For anyone looking at this with a similar problem the answer is in the "modelState" the item.userId was my issue. There was a property in my model that was not represented in the online database. So it would just fail. I wish it gave more info, but maybe people that know this stuff know how to find this and this is more than enough info for them

Answers

  • JohnButlerJohnButler USMember ✭✭
    Accepted Answer

    I finally figured it out!!!! Oh man.. that was over a week set back :disappointed:

    For anyone looking at this with a similar problem the answer is in the "modelState" the item.userId was my issue. There was a property in my model that was not represented in the online database. So it would just fail. I wish it gave more info, but maybe people that know this stuff know how to find this and this is more than enough info for them

Sign In or Register to comment.