APIs & services / portfolio-service

Download farming-model attachments in bulk.

Endpointtoday's app
Call
GET /gateway/portfolio-service/api/v1/farming-model/attachment/bulk?farmingModelIds=
Service
portfolio-service
Features
Data download (Cadre), Farmer hub (option tiles), ATM model (Anytime Money plot), 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

Online bulk read after farming models are downloaded (data download, farmer hub refresh). Farming model ids in chunks of 50; for each model the newest image becomes the ATM photo and the newest KML is saved and linked as its geofence (updateATMGeoFencingByTileId). Chunk failures are collected and fail the step.

Headers

HeaderValueNotes
X-SESSIONID<session token>Added by AuthInterceptor (data/net/AuthInterceptor.kt) when the call does not set it; on HTTP 401 or 400 the interceptor invalidates the token, fetches a new one and retries the request once.

Parameters

ParamInRequiredExampleNotes
farmingModelIdsqueryYes5501,5502CSV, chunk of 50.

Request

No body. farming model ids (chunk 50)

Response

Example response body (synthetic data)
{
  "5501": [
    {
      "attachmentDateTime": "2026-07-01T10:15:00.000+05:30",
      "fileName": "atm_5501.jpg",
      "attachmentKind": "ATTACHMENT_KIND.IMAGE",
      "attachmentKindMetaData": null,
      "attachmentKindIdentifier": 6001,
      "attachmentUUID": "a1b2c3d4-0000-4000-8000-000000000401",
      "id": 88001,
      "uuid": "a1b2c3d4-0000-4000-8000-000000000402",
      "tempAttachmentURL": "https://<storage-host>/signed/pli_6001.jpg?sig=<redacted>",
      "appCreatedAt": "1780000000000"
    },
    {
      "attachmentDateTime": "2026-07-01T10:15:00.000+05:30",
      "fileName": "geofence_tile_0001.kml",
      "attachmentKind": "ATTACHMENT_KIND.GEOFENCE",
      "attachmentKindMetaData": "<?xml version=\"1.0\"?><kml>...polygon...</kml>",
      "attachmentKindIdentifier": 6001,
      "attachmentUUID": "a1b2c3d4-0000-4000-8000-000000000401",
      "id": 88002,
      "uuid": "a1b2c3d4-0000-4000-8000-000000000402",
      "tempAttachmentURL": "https://<storage-host>/signed/geofence_tile_0001.kml?sig=<redacted>",
      "appCreatedAt": "1780000000000"
    }
  ]
}
FieldTypeRequiredNotes
<farmingModelId> (map key)stringFarming model id.
<farmingModelId>[].idintegerAttachment id; highest id per type wins. Stored as imageAttachmentId / geoFenceAttachments / geoFencingFileId.
<farmingModelId>[].fileNamestringExtension decides handling: .jpg/.jpeg/.png/.webp = photo, .kml = geofence.
<farmingModelId>[].tempAttachmentURLstringSigned URL saved as the image URL (or KML path fallback).
<farmingModelId>[].attachmentKindMetaDatastringFor KML, the file content; saved to files/geofencing/<fileName>.
<farmingModelId>[].attachmentDateTimestringSaved as geoFencingCreatedOn.
<farmingModelId>[].appCreatedAtstringSaved as imageCreatedAt.
<farmingModelId>[].attachmentKind, attachmentKindIdentifier, attachmentUUID, uuidmixedDeserialised but not read by the app.

Errors

StatusWhenWhat the app does
401 / 400Session token expiredAuthInterceptor invalidates the token, gets a fresh session id and retries the request once.
any non-2xxOther failuresFailure collected; step throws.

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/option/OptionViewModel.kt