Queued create of a crop harvest (HARVEST POST via HarvestWorker) after the user saves a harvest in SelectHarvestBottomSheet; IePortfolioRepositoryImpl.saveHarvestLog stores the harvest_logs row, updates the crop's harvest status and triggers sync. The Retrofit saveHarvestLog (online) method still exists but its only call is commented out, so in practice this is queue-only. The response body is the new harvest id, saved to harvest_logs; failures retry.
Headers
Header
Value
Notes
X-SESSIONID
<session token>
Stamped when the operation is queued (dooWithRetry) and re-set by CoreAPI at send time; refreshed on 401.
X-REQUESTID
<uuid v4>
Idempotency key generated by OperationManagerImpl.createOperation for POST/PUT/PATCH when the op enters the offline queue.
X-ACK-REQUESTID
<X-REQUESTID of an earlier completed op>
Added by SyncQueueProcessor for POST/PUT/PATCH: acknowledges a request id the device already saw succeed.
Content-Type
application/json
Added by CoreAPI.
Parameters
Param
In
Required
Example
Notes
id
path
Yes
40001
Farmer IE id (HarvestLogs.ownerId); op is not built if ownerId is null.
Quantity + UoM (uom 'name' and measurementType 'name'/'code' are Gson serialised names).
earlyHarvestReason / interestedInCropMarketing
mixed
No
Form answers.
ownerId / ownerEntityType / uuid / id
mixed
Yes
Owner farmer, client uuid (ledger entity id), local id.
Response
Example response body (synthetic data)
9301
Field
Type
Required
Notes
(body)
integer
New harvest id -> harvest_logs.id (updateHarvestId). If the body is not an integer the ledger is not closed.
Errors
Status
When
What the app does
401
Session token expired or invalid
CoreAPI invalidates the session id and retries once immediately; if still failing the op stays in the queue (TryAgain.LATER).
500
Server error on a /gateway URL
BaseResponseHandler fetches a new session id (first 5 attempts) and returns TryAgain.LATER; retried per RetryScheduler policy (retry threshold/delay come from app config).
503
Service unavailable
CoreAPI retries once immediately, then the op is retried later by the sync queue.
any non-2xx
Any other failure
Handler onError -> TryAgain.LATER (op stays queued and is visible in Pending Sync); a row is written to the local error_log table (Sync Error Log screen) with URL, body, headers and raw response; every 10th attempt the op is mirrored to Firestore for support.