APIs & services / asset-service

Update land or cattle assets.

Endpointtoday's app
Call
PATCH /gateway/asset-service/api/v1/assets/
Service
asset-service
Features
Land assets, Leased land, Livestock
When
Queued sync (FARMER_ASSETS PATCH)
Auth
X-SESSIONID stamped when queued (CoreAPI dooWithRetry); X-REQUESTID idempotency key
In the App Service

Use case

Updates an existing asset after an edit on the Land, Leased Land or Livestock screens, including land authentication. A FARMER_ASSETS PATCH ledger entry triggers FarmerAssetsWorker.patch, which sends a one-element list (isListMessage=true) through the offline queue. On 2xx, FarmerAssetsPatchRH logs success (ErrorLogUtils) and closes the ledger; the response body is not read. On error it retries later and applies the same "Integrity" fix for a null quantity as POST.

Headers

HeaderValueNotes
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.
Content-Typeapplication/jsonSet by the HTTP client for JSON bodies.

Request

Example request body (synthetic data)
[
  {
    "id": 5501,
    "owningEntityId": "880001",
    "assetCode": "AST-0001",
    "dateOfPurchase": null,
    "ownerEntityType": {
      "code": "OWNER_ENTITY.IE",
      "refClass": {
        "code": "OWNER_ENTITY"
      }
    },
    "assetCategory": {
      "code": "ASSET_CATEGORY.LAND",
      "refClass": {
        "code": "ASSET_CATEGORY"
      },
      "labels": [
        {
          "id": 1,
          "text": "Land",
          "language": {
            "code": "ENG",
            "label": "English"
          }
        }
      ]
    },
    "assetSubCategory": {
      "code": "ASSET_SUB_CATEGORY.LAND_OWNED",
      "refClass": {
        "code": "ASSET_SUB_CATEGORY"
      },
      "labels": [
        {
          "id": 2,
          "text": "Owned",
          "language": {
            "code": "ENG",
            "label": "English"
          }
        }
      ]
    },
    "assetFunctionality": {
      "code": "ASSET_FUNCTIONALITY.IRRIGATED",
      "refClass": {
        "code": "ASSET_FUNCTIONALITY"
      },
      "labels": []
    },
    "quality": null,
    "totalQuantity": {
      "id": 9001,
      "value": 1.5,
      "uoM": {
        "symbol": "ac",
        "code": "UOM.ACRE",
        "name": "Acre",
        "description": null,
        "measurementType": {
          "code": "AREA",
          "name": "Area",
          "description": null,
          "globalRefClass": {
            "code": "MEASUREMENT_TYPE",
            "name": null,
            "description": null
          }
        }
      }
    },
    "nameList": [
      {
        "id": 77,
        "text": "Survey 12/3",
        "language": {
          "code": "ENG",
          "label": "English"
        }
      }
    ],
    "assetSpecsList": [
      {
        "id": 300,
        "specName": "SURVEY_NUMBER",
        "specValue": "12/3",
        "uuid": "0f0e0d0c-0000-4000-8000-000000000001"
      }
    ],
    "appMillMetadata": {
      "ie_appId": "IE-APP-UUID-0001"
    },
    "assetCheckSum": "9e107d9d372bb6826bd81d3542a419d6",
    "authenticated": true,
    "notes": null,
    "isLeased": false,
    "leaseStatus": null,
    "leaseType": null,
    "leasedFromOwningEntityId": null,
    "leasedToOwningEntityId": null,
    "leasedFromAssetId": null,
    "leasedFromWorknodeCode": null,
    "leasedFromWorknodeType": null,
    "isActive": true,
    "inactiveReason": null,
    "inactiveAt": null,
    "createdAt": "2025-06-01T10:00:00Z",
    "lastModifiedAt": "2025-06-02T10:00:00Z",
    "appCreatedAt": "1748772000000",
    "appLastModifiedAt": "1748858400000",
    "createdByApp": 1,
    "lastModifiedByApp": 1,
    "createdFromDevice": "DEVICE-XXXX",
    "lastUpdatedFromDevice": "DEVICE-XXXX"
  }
]
FieldTypeRequiredNotes
[].idintYesServer asset id. 0 or null when creating.
[].owningEntityIdstringYesFarmer IE id (server). If it is not numeric, replacePlatformValues swaps in the server IE id resolved from appMillMetadata.ie_appId.
[].assetCodestringNoBusiness code of the asset. Also sent with the geofence upload.
[].dateOfPurchasestring|nullNoLivestock purchase date.
[].ownerEntityType.codestringNoOWNER_ENTITY.IE for farmers, OWNER_ENTITY.BRIDGE_USER for the cadre's own assets (FarmerAssetsMapper).
[].assetCategory.code / assetSubCategory.code / assetFunctionality.code / quality.codestringNoValues from the asset ref data (land or livestock picker on the Land and Livestock screens).
[].*.labels[]arrayNoLocalised labels, stored in asset_*_labels tables.
[].totalQuantity.valuedoubleNoLand extent (acres) or head count, from the Extent field. On an "Integrity" error, the RH sets a null value to 0.0 and re-queues.
[].totalQuantity.uoMobjectNoUnit of measure (code, symbol, measurementType).
[].nameList[].textstringNoAsset name or survey label. PII: may contain survey or land identifiers.
[].assetSpecsList[]arrayNospecName/specValue pairs (for example survey number). PII: land record identifiers.
[].appMillMetadata.ie_appIdstringNoLocal app id of the farmer, used to resolve owningEntityId offline.
[].assetCheckSumstringNoMD5 of the asset name plus total quantity (IeAsset.setMD5Hash). The server uses it to detect checksum mismatches (ERR_PLATFORM_ASSET_CHECKSUM_MISMATCH).
[].authenticatedbooleanNoLand authenticated toggle.
[].isLeased, leaseStatus, leaseType, leasedFrom*/leasedTo*mixedNoLeased-land screen fields.
[].isActive, inactiveReason, inactiveAtboolean/string/longNoSoft-delete state. inactiveReason also goes in the DELETE query.
[].createdAt, lastModifiedAt, appCreatedAt, appLastModifiedAt, createdByApp, lastModifiedByApp, createdFromDevice, lastUpdatedFromDevicestring/longNoAudit fields. Device ids are device identifiers.
[].geoFencingFileName, geoFencingCreatedOn, geoFencingFilePath, geoFencingIdstring/intNoLocal-only Room columns that Moshi/Gson also serialise. The server is not known to read them.

Response

Example response body (synthetic data)
[
  {
    "id": 5501,
    "owningEntityId": "880001",
    "assetCode": "AST-0001",
    "dateOfPurchase": null,
    "ownerEntityType": {
      "code": "OWNER_ENTITY.IE",
      "refClass": {
        "code": "OWNER_ENTITY"
      }
    },
    "assetCategory": {
      "code": "ASSET_CATEGORY.LAND",
      "refClass": {
        "code": "ASSET_CATEGORY"
      },
      "labels": [
        {
          "id": 1,
          "text": "Land",
          "language": {
            "code": "ENG",
            "label": "English"
          }
        }
      ]
    },
    "assetSubCategory": {
      "code": "ASSET_SUB_CATEGORY.LAND_OWNED",
      "refClass": {
        "code": "ASSET_SUB_CATEGORY"
      },
      "labels": [
        {
          "id": 2,
          "text": "Owned",
          "language": {
            "code": "ENG",
            "label": "English"
          }
        }
      ]
    },
    "assetFunctionality": {
      "code": "ASSET_FUNCTIONALITY.IRRIGATED",
      "refClass": {
        "code": "ASSET_FUNCTIONALITY"
      },
      "labels": []
    },
    "quality": null,
    "totalQuantity": {
      "id": 9001,
      "value": 1.5,
      "uoM": {
        "symbol": "ac",
        "code": "UOM.ACRE",
        "name": "Acre",
        "description": null,
        "measurementType": {
          "code": "AREA",
          "name": "Area",
          "description": null,
          "globalRefClass": {
            "code": "MEASUREMENT_TYPE",
            "name": null,
            "description": null
          }
        }
      }
    },
    "nameList": [
      {
        "id": 77,
        "text": "Survey 12/3",
        "language": {
          "code": "ENG",
          "label": "English"
        }
      }
    ],
    "assetSpecsList": [
      {
        "id": 300,
        "specName": "SURVEY_NUMBER",
        "specValue": "12/3",
        "uuid": "0f0e0d0c-0000-4000-8000-000000000001"
      }
    ],
    "appMillMetadata": {
      "ie_appId": "IE-APP-UUID-0001"
    },
    "assetCheckSum": "9e107d9d372bb6826bd81d3542a419d6",
    "authenticated": true,
    "notes": null,
    "isLeased": false,
    "leaseStatus": null,
    "leaseType": null,
    "leasedFromOwningEntityId": null,
    "leasedToOwningEntityId": null,
    "leasedFromAssetId": null,
    "leasedFromWorknodeCode": null,
    "leasedFromWorknodeType": null,
    "isActive": true,
    "inactiveReason": null,
    "inactiveAt": null,
    "createdAt": "2025-06-01T10:00:00Z",
    "lastModifiedAt": "2025-06-02T10:00:00Z",
    "appCreatedAt": "1748772000000",
    "appLastModifiedAt": "1748858400000",
    "createdByApp": 1,
    "lastModifiedByApp": 1,
    "createdFromDevice": "DEVICE-XXXX",
    "lastUpdatedFromDevice": "DEVICE-XXXX"
  }
]
FieldTypeRequiredNotes
[]FarmerAssets[]Not read by the app. The RH reuses the request message.

Errors

StatusWhenWhat the app does
401Session expiredCoreAPI invalidates the session id and retries once. If it still fails, the response handler returns TryAgain.LATER and the operation stays in the queue.
409Duplicate X-REQUESTIDSyncQueueProcessor records the request id and swaps in a fresh X-REQUESTID for the next attempt.
4xx/5xx (other)Server rejects or failsonError returns TryAgain.LATER (FarmerAssetsPatchRH). 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.

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/FarmerAssetsPatchRH.kt