APIs & services / asset-service

Download land and cattle assets for a chunk of farmers (or the cadre, with OWNER_ENTITY.BRIDGE_USER).

Endpointtoday's app
Call
GET /gateway/asset-service/api/v1/assets/ownerEntities?ownerEntityIdList=&ownerEntityType=OWNER_ENTITY.IE
Service
asset-service
Features
Data download (Cadre), Data download (Unit / FMT), Farmer hub (option tiles), Land assets, Livestock, Side menu
When
Data download; per-farmer refresh
Auth
X-SESSIONID header (AuthInterceptor adds it; re-auth on 401/400)
In the App Service

Use case

Downloads every land and livestock asset owned by a list of farmers. It is called online during the cadre data download (DataSetupViewModel.syncFarmerAssets) and the unit data download (UnitDataSetupViewModel, SetupForUnitInChargeLogin), in chunks of the ref-data asset pagination limit (default 30 IE ids). It is also called for one farmer from the farmer hub (OptionViewModel.syncFarmerData) and the Land screen refresh (IeAssetRepositoryImpl.fetchAssetOnline). The side-menu user-data refresh (FetchUserDataWorker -> SetupForUser) calls it with ownerEntityType=OWNER_ENTITY.BRIDGE_USER for the cadre's own assets. Rows that still have a pending local sync are skipped. The rest are saved to farmerassets, and assets the server no longer returns are removed (LoadMoreDataUtils.removeAssetDataWhenNotFound). On failure the download step is marked ERROR and the dependent attachment step is skipped.

Headers

HeaderValueNotes
X-SESSIONID<session id>Not declared on the Retrofit method; AuthInterceptor (data/net/AuthInterceptor.kt) adds it. On a 401 or 400 it re-authenticates and retries once.

Parameters

ParamInRequiredExampleNotes
ownerEntityIdListqueryYes880001Retrofit List<String>, sent as repeated params: ownerEntityIdList=880001&ownerEntityIdList=880002. Chunk size comes from ref data (AppUtils.getFarmerAssetPaginationLimit), default 30.
ownerEntityTypequeryYesOWNER_ENTITY.IEOWNER_ENTITY.IE for farmers. OWNER_ENTITY.BRIDGE_USER for the logged-in cadre's own assets (SetupForUser).

Request

No body. ownerEntityIdList (IE ids), ownerEntityType

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
idintServer asset id. 0 or null when creating.
owningEntityIdstringFarmer IE id (server). If it is not numeric, replacePlatformValues swaps in the server IE id resolved from appMillMetadata.ie_appId.
assetCodestringBusiness code of the asset. Also sent with the geofence upload.
dateOfPurchasestring|nullLivestock purchase date.
ownerEntityType.codestringOWNER_ENTITY.IE for farmers, OWNER_ENTITY.BRIDGE_USER for the cadre's own assets (FarmerAssetsMapper).
assetCategory.code / assetSubCategory.code / assetFunctionality.code / quality.codestringValues from the asset ref data (land or livestock picker on the Land and Livestock screens).
*.labels[]arrayLocalised labels, stored in asset_*_labels tables.
totalQuantity.valuedoubleLand 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.uoMobjectUnit of measure (code, symbol, measurementType).
nameList[].textstringAsset name or survey label. PII: may contain survey or land identifiers.
assetSpecsList[]arrayspecName/specValue pairs (for example survey number). PII: land record identifiers.
appMillMetadata.ie_appIdstringLocal app id of the farmer, used to resolve owningEntityId offline.
assetCheckSumstringMD5 of the asset name plus total quantity (IeAsset.setMD5Hash). The server uses it to detect checksum mismatches (ERR_PLATFORM_ASSET_CHECKSUM_MISMATCH).
authenticatedbooleanLand authenticated toggle.
isLeased, leaseStatus, leaseType, leasedFrom*/leasedTo*mixedLeased-land screen fields.
isActive, inactiveReason, inactiveAtboolean/string/longSoft-delete state. inactiveReason also goes in the DELETE query.
createdAt, lastModifiedAt, appCreatedAt, appLastModifiedAt, createdByApp, lastModifiedByApp, createdFromDevice, lastUpdatedFromDevicestring/longAudit fields. Device ids are device identifiers.
(paging)n/aNo paging; the whole chunk comes back in one response.

Errors

StatusWhenWhat the app does
non-2xxAny failure for a chunkData download throws "Failed to fetch farmer assets: <code>", marks farmer_assets and farmer_asset_attachments as ERROR and stops. The farmer hub sync posts an error status. SetupForUser logs a Crashlytics non-fatal and, on a 401, refreshes the session.
401/400Session invalidAuthInterceptor re-authenticates and retries once.

Source

  • data/src/main/java/org/mindtree/app/agricultor/data/setup/SetupService.kt
  • app/src/main/java/org/platformcommons/urvi/view/datasetup/DataSetupViewModel.kt
  • app/src/main/java/org/platformcommons/urvi/view/datasetup/UnitDataSetupViewModel.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/setup_new/SetupForUnitInChargeLogin.kt
  • app/src/main/java/org/platformcommons/urvi/view/option/OptionViewModel.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/repository/impl/IeAssetRepositoryImpl.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/setup/SetupForUser.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/service/FetchUserDataWorker.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/entity/FarmerAssets.kt