APIs & services / sync-service

Upload a snapshot of the whole offline queue for support.

Endpointtoday's app
Call
POST /sync-service/api/v1/data/so
Service
sync-service
Features
Sync error log, Settings
When
Periodic 6 h; Settings "send data"; before clear app data
Auth
X-SESSIONID header (AuthInterceptor adds it; re-auth on 401/400)
In the App Service

Use case

Uploads a support snapshot of the entire offline queue (SELECT * FROM OPERATION in SYNC_QUEUE_DB). Triggers: SendSyncDetailsDataWorker, a periodic job every 6 hours (network required) set up in HomeActivity; the two "send data" actions in Settings (DataUtil.sendSyncQueueData); and the one-time clear-app-data migration in HomeActivity.clearAppData (dataBeforeClearAppData=true). That migration also zips SYNC_QUEUE_DB to Firebase Storage first, and if this POST succeeds it calls ActivityManager.clearApplicationUserData(). The call is online and the response is ignored apart from success. On failure the worker reports failure; the clear-data flow shows "Something went wrong / try again" and loops until the upload succeeds.

Headers

HeaderValueNotes
X-SESSIONID<session id>Passed explicitly as a @Header by the caller (AndroidSessionManager.sessionId). AuthInterceptor also fills it when missing, and on a 401 or 400 it invalidates the token, fetches a new one and retries once.
Content-Typeapplication/jsonSet by the HTTP client for JSON bodies.

Request

Example request body (synthetic data)
{
  "totalSyncCount": 14,
  "cadreLogin": "cadre_a",
  "appVersion": "3.2.1",
  "appVersionCode": 125,
  "date": "02 June 2025, 10:15:00",
  "requestUUID": "r0000000-0000-4000-8000-000000000001",
  "dataBeforeClearAppData": false,
  "syncQueueData": [
    {
      "operationIdentifier": "op-0000-4000-8000-000000000001",
      "url": "/gateway/asset-service/api/v1/assets/",
      "method": "POST",
      "message": "{\"owningEntityId\":\"880001\",\"assetCode\":\"AST-0001\",\"totalQuantity\":{\"value\":1.5}}",
      "status": 500,
      "attemptCount": 12,
      "params": "{}",
      "user": "1001",
      "metaJson": "{\"syncLedger\":{...}}",
      "uriParams": "{}",
      "requestHeaders": "{X-SESSIONID=<session id>, X-REQUESTID=<uuid>}",
      "responseHandler": "org.mindtree.app.agricultor.data.sync.rh.FarmerAssetsPostRH",
      "responseHeaders": null,
      "messageDtoClass": "org.mindtree.app.agricultor.data.entity.FarmerAssets",
      "evaluated": false,
      "isListMessage": false,
      "createTime": "Jun 1, 2025 10:00:00 AM",
      "updateTime": "Jun 2, 2025 10:00:00 AM",
      "nextAttempt": "Jun 2, 2025 11:00:00 AM"
    }
  ]
}
FieldTypeRequiredNotes
totalSyncCountlongYesSyncHelper.getQueueSize(coreAPI).
cadreLoginstringYesPII: login id (userId before "@@").
appVersion / appVersionCodestring / intYesBuild info.
datestringYesFormat "dd MMMM yyyy, HH:mm:ss" (English locale).
requestUUIDstringYesRandom UUID per upload.
dataBeforeClearAppDatabooleanNoTrue only from the clear-app-data flow.
syncQueueData[]OperationEntity[]YesPII: every queued operation in full. message holds raw request bodies (farmer profiles, land, crop, endorsement and comment payloads), and requestHeaders holds the X-SESSIONID session token. getSyncOperationData ignores its filter flag and always sends all rows, not just failing ones.
syncQueueData[].operationIdentifier, url, method, status, attemptCount, evaluated, isListMessagemixedYesQueue state per operation.
syncQueueData[].messagestring (JSON)NoPII: raw body.
syncQueueData[].requestHeadersstringNoPII/secret: contains the session token.
syncQueueData[].params, uriParams, metaJson, user, responseHandler, responseHeaders, messageDtoClass, createTime, updateTime, nextAttempt, resultmixedNoRaw queue columns. The result blob is copied too.

Response

Example response body (synthetic data)
{
  "status": "ok"
}
FieldTypeRequiredNotes
(body)JsonObjectMust be non-null for success. Its contents are not read by the app.

Errors

StatusWhenWhat the app does
non-2xx / null bodyUpload rejectedWorker: failure, retried on the next 6-hour run. Settings: callback(false). Clear-data: a retry dialog appears and app data is not cleared.
401/400Session invalidAuthInterceptor re-authenticates and retries once.

Source

  • app/src/main/java/org/platformcommons/urvi/datasource/network/URLInjector.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/network/retrofit/APIInterface.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/service/SendSyncDetailsDataWorker.kt
  • app/src/main/java/org/platformcommons/urvi/utility/DataUtil.kt
  • app/src/main/java/org/platformcommons/urvi/view/home/HomeActivity.kt
  • app/src/main/java/org/platformcommons/urvi/view/home/SettingsActivity.kt
  • app/src/main/java/org/platformcommons/urvi/vo/SyncOperationData.kt