Continue trying to put changes even after 401 error

R Ruben Ruben 3 years ago
48 5 0

Hi,

In the app i'm currently developing, my source adapter connects to a web service in order to fetch the data it needs. This web service uses a token that is only valid for 1 hour. I want the user to be able to keep working with an invalid token and that all changes are stored in the local db until he gets a valid token again (when all changes would be synced)

The problem is that once the Rhoconnect gives error 401 after trying to put, post or delete anything, it won't try to repeat that operation in the following sync (even if the sync succeeds).

I'd like the behaviour to be the same as when the user tries to do any operation without having a valid connection; where it will try to put/post/delete until it succeeds.

I can understand why this is the default behaviour for 401 errors, but is there any way to change this?

Thanks,

Rubén

Please register or login to post a reply

5 Replies

B Brian Moore

When an error is encountered on the client you need to handle the error in your sync notification callback. By default if you do not handle the error you will encounter the behavior you see here.

Please see this documentation page:
Rhomobile | Synchronization with Rhodes

There is a section there titled "Server error processing on the client". While this document is labeled for 2.2, it also applies to 4.x.

R Ruben Ruben

I've found this 4.1 document: http://docs.rhomobile.com/en/4.1.0/api/NewORMModel

There is a method called onSyncCreateError, but one of its params is the array of objects. I'm not sure what to input here or when to call this method, has anyone used this?

R Ruben Ruben

Hi Brian,

Thanks, once again I was missing this 2.2 document. However, I feel like its poorly described. I'm trying to get it to work on Javascript with no success. Any idea on how the syntax and usage would be?

R Ruben Ruben

Any news on this? I've been trying further by using custom exceptions on the source adapter and using different combination of parameters in the doSync and doSyncSource methods from the RhoconnectClient API with no success.

K Kutir Mobility

Ruben,
Is it possible for you to manually try syncing when you read the response code as 401?

Visnupriya R
Kutir Mobility

CONTACT
Can’t find what you’re looking for?