Saves endorsement decisions (endorse, flag or send for review) on two paths. (1) Offline queue: endorsing one VO, SHG or farmer writes endorsement_entity plus an ENDORSEMENT POST sync-ledger entry. EndorsementWorker builds EndorsementEntity.post() (a one-item list) and queues it with dooWithRetry. On success EndorsementPostRH stores the returned id, closes the ledger, and sends an FCM data message to /topics/urvi_endorsement_status (see the FCM entry). (2) Online bulk endorse from the farmer list (EndorsementViewModel.endorseBulkFarmers) posts the whole selection directly and, on success, updates the local rows. Note: this path never posts a success Resource, so the UI only ever sees errors. Offline-path errors stay in the queue and retry later.
Headers
Header
Value
Notes
X-SESSIONID
<session id>
Stamped by CoreAPI when the queued operation runs (CoreAPIDefaultImpl.doOperation). On a 401 the token is invalidated and the call retried. BaseResponseHandler also refreshes the session after a 500 on a gateway URL (first 5 attempts).
X-REQUESTID
<uuid v4>
Idempotency key added by the offline queue (OperationManagerImpl). A 409 replaces it with a new UUID. It is removed for multipart requests.
Local file path of the abstract, also serialised. The server is not known to read it.
[].timestamp
long
No
Endorsement time (epoch ms).
[].createdAt
long
No
Mapped to created_at. FetchEndorsementDataWorker drops rows older than ref-data endorsementStartDate.
Response
Example response body (synthetic data)
[
3101
]
Field
Type
Required
Notes
[0]
int
Queued path: rawResponse has "[" and "]" stripped and is parsed as the new endorsement id (Data.repository.updateEndorsementId). The online path declares Call<Any> and ignores the body.
Errors
Status
When
What the app does
401
Session expired
CoreAPI invalidates the session id and retries once. If it still fails, the response handler returns TryAgain.LATER and the operation stays in the queue.
409
Duplicate X-REQUESTID
SyncQueueProcessor records the request id and swaps in a fresh X-REQUESTID for the next attempt.
4xx/5xx (other)
Server rejects or fails
onError returns TryAgain.LATER (EndorsementPostRH). Each failure is logged in the local error_log table (URL, body, headers). Every 10th attempt (up to attempt 5000) the whole operation is copied to Firestore urvi_sync_log. A 500 on a gateway URL in the first 5 attempts forces a session refresh.
non-2xx (online bulk)
Bulk save fails
Local rows are not updated. No success or error is posted unless an exception is thrown (bug).