Azure Mobile App Sync Service Push Failing to insert or update












0














I have an Azure Mobile App Service running with Table Controllers and a local SQLite store using the Microsoft.Azure.Mobile.Client and Microsoft.Azure.Mobile.Client.SQLiteStore Nuget packages as demonstrated by Microsoft's documentation.



From a Xamarin.Forms application I've implemented an entity using direct calls to the Azure service using the live server data and had no problems.



Trying to do the same using the offline sync capabilities the Azure SDK provides I can pull changes down from the server to the client with no problems, but trying to change or insert records on the client then pushing the changes fails.



Client side base entity class:



using System;
using Microsoft.WindowsAzure.MobileServices;

public class TableObject
{
public string Id { get; set; }

[UpdatedAt]
public DateTimeOffset? UpdatedAt { get; set; }

[CreatedAt]
public DateTimeOffset? CreatedAt { get; set; }

[Version]
public string Version { get; set; }

[Deleted]
public bool Deleted { get; set; }
}


Client Side Model:



public class UserData : TableObject
{
public string UserId { get; set; }
// Other properties

public UserData () { }
public UserData (UserData userData) : base(userData)
{
UserId = userData.UserId;
}

public async Task<User> User()
{
return await Database.Instance.GetItemAsync<User>(x => x.Id == UserId);
}
}


Server Model:



public class UserData : EntityData
{
[ForeignKey("User")]
public string UserId { get; set; }
public User User { get; set; }
// Other properties
}


My reproduction steps:




  1. From client perform post to an API controller inserting a new User record in the server database. Success

  2. Perform Push from client using sync service (pushes no records). Success

  3. Pull new user record from server to client using sync service. Success

  4. Create UserData records setting UserId and saving it to the client local store using the sync service. Success


  5. Push new record from local store to server using sync service. Fails



    catch (MobileServicePushFailedException exc)
    {
    if (exc.PushResult != null)
    {
    syncErrors = exc.PushResult.Errors;
    }
    }




exc stack trace:



at Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncContext+<ExecuteSyncAction>d__34.MoveNext () [0x00090] in <24dbefba60fd49f4b193cdf58abf3290>:0 
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncContext+<PushAsync>d__33.MoveNext () [0x00143] in <24dbefba60fd49f4b193cdf58abf3290>:0


PushResult has a single failed insert and the item contains 2 properties (Id, UserId). Result and Status are null, Handled is false, and the post method in the table controller is never called. Keep in mind during pull the Get method on the table controller is called.



This also happens if we pull the user record, update it locally, then try pushing it up.










share|improve this question
























  • Try adding a MobileServiceSyncHandler as described in stackoverflow.com/questions/52288943/… to get a better idea of what the underlying error is when you try doing a Push.
    – Eric Hedstrom
    Jan 2 at 20:04










  • I have tried adding a MobileServiceSyncHandler, both the default one and a custom one. The problem doesn't appear to be the error with a database update, but rather it is that the push never even reaches the Table controllers during the process. After calling PushAsync() the black box that is this method never reaches the table controller in the server project. On startup the PullAsync() methods successfully reach the table controllers, but then pushing it doesn't. I was wondering if this was an authentication issue but was able to call the table controllers from PostMan with no problems.
    – Dustin
    2 days ago
















0














I have an Azure Mobile App Service running with Table Controllers and a local SQLite store using the Microsoft.Azure.Mobile.Client and Microsoft.Azure.Mobile.Client.SQLiteStore Nuget packages as demonstrated by Microsoft's documentation.



From a Xamarin.Forms application I've implemented an entity using direct calls to the Azure service using the live server data and had no problems.



Trying to do the same using the offline sync capabilities the Azure SDK provides I can pull changes down from the server to the client with no problems, but trying to change or insert records on the client then pushing the changes fails.



Client side base entity class:



using System;
using Microsoft.WindowsAzure.MobileServices;

public class TableObject
{
public string Id { get; set; }

[UpdatedAt]
public DateTimeOffset? UpdatedAt { get; set; }

[CreatedAt]
public DateTimeOffset? CreatedAt { get; set; }

[Version]
public string Version { get; set; }

[Deleted]
public bool Deleted { get; set; }
}


Client Side Model:



public class UserData : TableObject
{
public string UserId { get; set; }
// Other properties

public UserData () { }
public UserData (UserData userData) : base(userData)
{
UserId = userData.UserId;
}

public async Task<User> User()
{
return await Database.Instance.GetItemAsync<User>(x => x.Id == UserId);
}
}


Server Model:



public class UserData : EntityData
{
[ForeignKey("User")]
public string UserId { get; set; }
public User User { get; set; }
// Other properties
}


My reproduction steps:




  1. From client perform post to an API controller inserting a new User record in the server database. Success

  2. Perform Push from client using sync service (pushes no records). Success

  3. Pull new user record from server to client using sync service. Success

  4. Create UserData records setting UserId and saving it to the client local store using the sync service. Success


  5. Push new record from local store to server using sync service. Fails



    catch (MobileServicePushFailedException exc)
    {
    if (exc.PushResult != null)
    {
    syncErrors = exc.PushResult.Errors;
    }
    }




exc stack trace:



at Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncContext+<ExecuteSyncAction>d__34.MoveNext () [0x00090] in <24dbefba60fd49f4b193cdf58abf3290>:0 
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncContext+<PushAsync>d__33.MoveNext () [0x00143] in <24dbefba60fd49f4b193cdf58abf3290>:0


PushResult has a single failed insert and the item contains 2 properties (Id, UserId). Result and Status are null, Handled is false, and the post method in the table controller is never called. Keep in mind during pull the Get method on the table controller is called.



This also happens if we pull the user record, update it locally, then try pushing it up.










share|improve this question
























  • Try adding a MobileServiceSyncHandler as described in stackoverflow.com/questions/52288943/… to get a better idea of what the underlying error is when you try doing a Push.
    – Eric Hedstrom
    Jan 2 at 20:04










  • I have tried adding a MobileServiceSyncHandler, both the default one and a custom one. The problem doesn't appear to be the error with a database update, but rather it is that the push never even reaches the Table controllers during the process. After calling PushAsync() the black box that is this method never reaches the table controller in the server project. On startup the PullAsync() methods successfully reach the table controllers, but then pushing it doesn't. I was wondering if this was an authentication issue but was able to call the table controllers from PostMan with no problems.
    – Dustin
    2 days ago














0












0








0







I have an Azure Mobile App Service running with Table Controllers and a local SQLite store using the Microsoft.Azure.Mobile.Client and Microsoft.Azure.Mobile.Client.SQLiteStore Nuget packages as demonstrated by Microsoft's documentation.



From a Xamarin.Forms application I've implemented an entity using direct calls to the Azure service using the live server data and had no problems.



Trying to do the same using the offline sync capabilities the Azure SDK provides I can pull changes down from the server to the client with no problems, but trying to change or insert records on the client then pushing the changes fails.



Client side base entity class:



using System;
using Microsoft.WindowsAzure.MobileServices;

public class TableObject
{
public string Id { get; set; }

[UpdatedAt]
public DateTimeOffset? UpdatedAt { get; set; }

[CreatedAt]
public DateTimeOffset? CreatedAt { get; set; }

[Version]
public string Version { get; set; }

[Deleted]
public bool Deleted { get; set; }
}


Client Side Model:



public class UserData : TableObject
{
public string UserId { get; set; }
// Other properties

public UserData () { }
public UserData (UserData userData) : base(userData)
{
UserId = userData.UserId;
}

public async Task<User> User()
{
return await Database.Instance.GetItemAsync<User>(x => x.Id == UserId);
}
}


Server Model:



public class UserData : EntityData
{
[ForeignKey("User")]
public string UserId { get; set; }
public User User { get; set; }
// Other properties
}


My reproduction steps:




  1. From client perform post to an API controller inserting a new User record in the server database. Success

  2. Perform Push from client using sync service (pushes no records). Success

  3. Pull new user record from server to client using sync service. Success

  4. Create UserData records setting UserId and saving it to the client local store using the sync service. Success


  5. Push new record from local store to server using sync service. Fails



    catch (MobileServicePushFailedException exc)
    {
    if (exc.PushResult != null)
    {
    syncErrors = exc.PushResult.Errors;
    }
    }




exc stack trace:



at Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncContext+<ExecuteSyncAction>d__34.MoveNext () [0x00090] in <24dbefba60fd49f4b193cdf58abf3290>:0 
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncContext+<PushAsync>d__33.MoveNext () [0x00143] in <24dbefba60fd49f4b193cdf58abf3290>:0


PushResult has a single failed insert and the item contains 2 properties (Id, UserId). Result and Status are null, Handled is false, and the post method in the table controller is never called. Keep in mind during pull the Get method on the table controller is called.



This also happens if we pull the user record, update it locally, then try pushing it up.










share|improve this question















I have an Azure Mobile App Service running with Table Controllers and a local SQLite store using the Microsoft.Azure.Mobile.Client and Microsoft.Azure.Mobile.Client.SQLiteStore Nuget packages as demonstrated by Microsoft's documentation.



From a Xamarin.Forms application I've implemented an entity using direct calls to the Azure service using the live server data and had no problems.



Trying to do the same using the offline sync capabilities the Azure SDK provides I can pull changes down from the server to the client with no problems, but trying to change or insert records on the client then pushing the changes fails.



Client side base entity class:



using System;
using Microsoft.WindowsAzure.MobileServices;

public class TableObject
{
public string Id { get; set; }

[UpdatedAt]
public DateTimeOffset? UpdatedAt { get; set; }

[CreatedAt]
public DateTimeOffset? CreatedAt { get; set; }

[Version]
public string Version { get; set; }

[Deleted]
public bool Deleted { get; set; }
}


Client Side Model:



public class UserData : TableObject
{
public string UserId { get; set; }
// Other properties

public UserData () { }
public UserData (UserData userData) : base(userData)
{
UserId = userData.UserId;
}

public async Task<User> User()
{
return await Database.Instance.GetItemAsync<User>(x => x.Id == UserId);
}
}


Server Model:



public class UserData : EntityData
{
[ForeignKey("User")]
public string UserId { get; set; }
public User User { get; set; }
// Other properties
}


My reproduction steps:




  1. From client perform post to an API controller inserting a new User record in the server database. Success

  2. Perform Push from client using sync service (pushes no records). Success

  3. Pull new user record from server to client using sync service. Success

  4. Create UserData records setting UserId and saving it to the client local store using the sync service. Success


  5. Push new record from local store to server using sync service. Fails



    catch (MobileServicePushFailedException exc)
    {
    if (exc.PushResult != null)
    {
    syncErrors = exc.PushResult.Errors;
    }
    }




exc stack trace:



at Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncContext+<ExecuteSyncAction>d__34.MoveNext () [0x00090] in <24dbefba60fd49f4b193cdf58abf3290>:0 
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.WindowsAzure.MobileServices.Sync.MobileServiceSyncContext+<PushAsync>d__33.MoveNext () [0x00143] in <24dbefba60fd49f4b193cdf58abf3290>:0


PushResult has a single failed insert and the item contains 2 properties (Id, UserId). Result and Status are null, Handled is false, and the post method in the table controller is never called. Keep in mind during pull the Get method on the table controller is called.



This also happens if we pull the user record, update it locally, then try pushing it up.







c# azure xamarin.forms azure-mobile-services offline-caching






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 28 '18 at 1:34









aliusman

9741219




9741219










asked Dec 28 '18 at 0:40









Dustin

11




11












  • Try adding a MobileServiceSyncHandler as described in stackoverflow.com/questions/52288943/… to get a better idea of what the underlying error is when you try doing a Push.
    – Eric Hedstrom
    Jan 2 at 20:04










  • I have tried adding a MobileServiceSyncHandler, both the default one and a custom one. The problem doesn't appear to be the error with a database update, but rather it is that the push never even reaches the Table controllers during the process. After calling PushAsync() the black box that is this method never reaches the table controller in the server project. On startup the PullAsync() methods successfully reach the table controllers, but then pushing it doesn't. I was wondering if this was an authentication issue but was able to call the table controllers from PostMan with no problems.
    – Dustin
    2 days ago


















  • Try adding a MobileServiceSyncHandler as described in stackoverflow.com/questions/52288943/… to get a better idea of what the underlying error is when you try doing a Push.
    – Eric Hedstrom
    Jan 2 at 20:04










  • I have tried adding a MobileServiceSyncHandler, both the default one and a custom one. The problem doesn't appear to be the error with a database update, but rather it is that the push never even reaches the Table controllers during the process. After calling PushAsync() the black box that is this method never reaches the table controller in the server project. On startup the PullAsync() methods successfully reach the table controllers, but then pushing it doesn't. I was wondering if this was an authentication issue but was able to call the table controllers from PostMan with no problems.
    – Dustin
    2 days ago
















Try adding a MobileServiceSyncHandler as described in stackoverflow.com/questions/52288943/… to get a better idea of what the underlying error is when you try doing a Push.
– Eric Hedstrom
Jan 2 at 20:04




Try adding a MobileServiceSyncHandler as described in stackoverflow.com/questions/52288943/… to get a better idea of what the underlying error is when you try doing a Push.
– Eric Hedstrom
Jan 2 at 20:04












I have tried adding a MobileServiceSyncHandler, both the default one and a custom one. The problem doesn't appear to be the error with a database update, but rather it is that the push never even reaches the Table controllers during the process. After calling PushAsync() the black box that is this method never reaches the table controller in the server project. On startup the PullAsync() methods successfully reach the table controllers, but then pushing it doesn't. I was wondering if this was an authentication issue but was able to call the table controllers from PostMan with no problems.
– Dustin
2 days ago




I have tried adding a MobileServiceSyncHandler, both the default one and a custom one. The problem doesn't appear to be the error with a database update, but rather it is that the push never even reaches the Table controllers during the process. After calling PushAsync() the black box that is this method never reaches the table controller in the server project. On startup the PullAsync() methods successfully reach the table controllers, but then pushing it doesn't. I was wondering if this was an authentication issue but was able to call the table controllers from PostMan with no problems.
– Dustin
2 days ago












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53952433%2fazure-mobile-app-sync-service-push-failing-to-insert-or-update%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53952433%2fazure-mobile-app-sync-service-push-failing-to-insert-or-update%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas