Endpointtoday's app
- Call
DELETE /gateway/asset-service/api/v1/assets/{id}?reason=- Service
- asset-service
- Features
- Land assets
- When
- Queued sync (FARMER_ASSETS DELETE)
- Auth
- X-SESSIONID stamped when queued (CoreAPI dooWithRetry); X-REQUESTID idempotency key
- In the App Service
Use case
Soft-deletes (disables) a land asset when the cadre removes it on the Land screen and picks a reason. A FARMER_ASSETS DELETE ledger entry triggers FarmerAssetsWorker.delete, which queues FarmerAssets.delete() with the id and inactiveReason in the URL and no body. On 2xx, AssetDeleteRH closes the ledger and deletes the local row. On error it reloads the local asset, rewrites the URL with the current server id and the reason (spaces replaced by "_"), and retries later. If the server says "already deactivated", BaseResponseHandler still returns the retry decision; the onSuccess shortcut is commented out, so this can loop.
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. |
Parameters
| Param | In | Required | Example | Notes |
|---|
id | path | Yes | 5501 | Server asset id. Rewritten on error from the local row. |
reason | query | Yes | Sold_land | inactiveReason picked by the user. Not URL-encoded when built in FarmerAssets.delete(). Spaces are replaced by "_" only on retry. |
Request
No body. id, reason
Response
| Field | Type | Required | Notes |
|---|
(body) | none | | Not read on success. On error the app reads errorCode and errorMessage from the JSON body but does not act on them. |
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 (AssetDeleteRH (rewrites the URL)). 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. |
4xx "already deactivated" | Asset already disabled on the server | Returns the onError retry decision (LATER). The local row is not removed (potential endless retry). |
Source
- data/src/main/java/org/mindtree/app/agricultor/data/entity/FarmerAssets.kt
- data/src/main/java/org/mindtree/app/agricultor/data/sync/work/FarmerAssetsWorker.kt
- data/src/main/java/org/mindtree/app/agricultor/data/sync/rh/AssetDeleteRH.kt
- data/src/main/java/org/mindtree/app/agricultor/data/sync/rh/BaseResponseHandler.kt