APIs & services / asset-service

Download asset attachments (KML geofences, images) in bulk.

Endpointtoday's app
Call
GET /gateway/asset-service/api/v1/asset/attachment/bulk?assetIds=
Service
asset-service
Features
Data download (Cadre), Farmer hub (option tiles), Land assets, Geofencing
When
Data download; per-farmer refresh
Auth
X-SESSIONID header (AuthInterceptor adds it; re-auth on 401/400)
In the App Service

Use case

After the asset download, this fetches the attachments (KML geofences) for the downloaded asset ids in CSV chunks (ref-data limit, default 50). Callers: DataSetupViewModel.syncFarmerAssetAttachments and OptionViewModel.syncFarmerAssetAttachments. IeAssetRepositoryImpl.fetchAssetOnline also calls it with one asset id when the local asset has no geofence. It is online only. For each asset the app keeps the newest ".kml" attachment, writes its inline content (attachmentKindMetaData) or temp URL to filesDir/geofencing, and updates the asset's geofencing columns. A failed chunk is collected and the step ends as ERROR, but the asset data already saved is kept.

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
assetIdsqueryYes5501,5502,5503Comma-separated server asset ids. Chunk size comes from AppUtils.getFarmerAssetAttachmentPaginationLimit(), default 50.

Request

No body. assetIds CSV (chunk 50)

Response

Example response body (synthetic data)
{
  "5501": [
    {
      "id": 42001,
      "uuid": "a1b2c3d4-0000-4000-8000-000000000042",
      "attachmentUUID": "a1b2c3d4-0000-4000-8000-000000000042",
      "fileName": "land_5501_geofence.kml",
      "attachmentDateTime": "2025-06-02 10:15:00",
      "attachmentKind": "ATTACHMENT_KIND.FILE",
      "attachmentKindMetaData": "<?xml version=\"1.0\"?><kml>...polygon...</kml>",
      "attachmentKindIdentifier": null,
      "tempAttachmentURL": "https://<signed-download-host>/<path>?<signature>",
      "appCreatedAt": "1748859300000"
    }
  ],
  "5502": []
}
FieldTypeRequiredNotes
<assetId> (object key)stringAsset id. Read as a Jackson ObjectNode and iterated with fields().
<assetId>[].idintAttachment id. Stored as geoFencingId. The highest id wins when picking the latest KML.
<assetId>[].uuid / attachmentUUIDstringNot read by the asset flows.
<assetId>[].fileNamestringFiltered on ".kml". Stored as geoFencingFileName.
<assetId>[].attachmentDateTimestringStored as geoFencingCreatedOn. Required (!!).
<assetId>[].attachmentKindMetaDatastringInline KML content, present when uploaded with saveFileContent=true. Written to filesDir/geofencing/<fileName>. PII: farm boundary coordinates.
<assetId>[].tempAttachmentURLstringSigned temporary URL. Used as the file path when there is no inline content; the farmer-hub path downloads it.
<assetId>[].attachmentKind, attachmentKindIdentifier, appCreatedAtstring/intNot read by the app.

Errors

StatusWhenWhat the app does
non-2xxChunk failsError collected. After all chunks, an exception marks farmer_asset_attachments as ERROR. Retry happens on the next download.
200 with malformed entryAn entry fails to parseThat asset is skipped and the failure noted. Other assets continue.

Source

  • data/src/main/java/org/mindtree/app/agricultor/data/setup/SetupService.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/setup/AttachmentResponse.kt
  • app/src/main/java/org/platformcommons/urvi/view/datasetup/DataSetupViewModel.kt
  • app/src/main/java/org/platformcommons/urvi/view/option/OptionViewModel.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/repository/impl/IeAssetRepositoryImpl.kt