APIs & services / portfolio-service

Refetch crop line items from the server (overwrite local after a compact-block edit lock, or pick a harvest target).

Endpointtoday's app
Call
GET /gateway/portfolio-service/api/v1/portfolios/portfolioLineItems?portfolioLineItems=
Service
portfolio-service
Features
Crop Actual (portfolio), Compact Block, Sync error log
When
After a compact-block sync error on a crop line item
Auth
X-SESSIONID header (AuthInterceptor adds it; re-auth on 401/400)
In the App Service

Use case

Online read by PortfolioLineItemUpdateWorker, scheduled when a queued PLI PUT fails because the line item is part of a compact block (editing not allowed). The server copy of the PLI overwrites the local row, the sync error is logged/cleared for that PLI, and the stuck sync ledger entry and queued operation are deleted. (SelectHarvestBottomSheet reads PLIs from the local DB, not this API.) On failure the worker returns failure and the error stays visible.

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
portfolioLineItemsqueryYes6001PLI id (single id from the failed op).

Request

No body. PLI ids

Response

Example response body (synthetic data)
[
  {
    "portfolioId": "3a9d0000-0000-4000-8000-000000000101",
    "id": 6001,
    "asset": "ASSET-CODE-0001",
    "uuid": "5f6c1d2e-0000-4000-8000-00000000a001",
    "practiceMasterCodes": [
      "PRACTICE.MULCHING",
      "PRACTICE.SEED_TREATMENT"
    ],
    "portfolioLineItemType": "PORTFOLIO_LINE_ITEM_TYPE.ACTUAL",
    "imageUrl": null,
    "isActive": true,
    "currentSeason": "KHARIF_2026",
    "methodMaster": {
      "id": 3,
      "uuid": "m-0003",
      "methodCode": "METHOD.PMDS"
    },
    "practiceMaster": {
      "practiceCode": "PRACTICE.MULCHING",
      "id": 4,
      "uuid": "p-0004"
    },
    "appCreatedAt": "1780000000000",
    "appLastModifiedAt": "1780000000000",
    "createdAt": null,
    "lastModifiedAt": null,
    "titleId": "TILE-0001",
    "assetId": 9001,
    "assetCheckSum": "<asset checksum>",
    "syncErrorId": null,
    "compactBlockId": null,
    "isLinkedToCompactBlock": false,
    "createdByApp": 109,
    "lastModifiedByApp": 109,
    "createdFromDevice": "<device id>",
    "lastUpdatedFromDevice": "<device id>",
    "geoFencingFileName": null,
    "geoFencingCreatedOn": null,
    "geoFencingFilePath": null,
    "geoFenceAttachments": null,
    "isEditable": true,
    "imageAttachmentId": null,
    "imageCreatedAt": null,
    "changeLog": null,
    "cropSeason": "KHARIF",
    "isAttachmentFetched": false,
    "portfolioProductLineItemList": [
      {
        "portfolioLineItemId": "5f6c1d2e-0000-4000-8000-00000000a001",
        "id": 7001,
        "uuid": "7b1e0000-0000-4000-8000-000000000201",
        "genericProduct": "PRODUCT.PADDY",
        "plannedStartDate": "2026-06-01",
        "plannedEndDate": "2026-10-31",
        "actualStartDate": "2026-06-05",
        "actualEndDate": null,
        "cropChangeReason": null,
        "assetProportion": {
          "id": 0,
          "uoM": {
            "code": "UOM.ACRE",
            "description": "Acre",
            "measurementType": {
              "code": "MEASUREMENT_TYPE.AREA",
              "description": "Area",
              "globalRefClass": {
                "code": "GREF.MEASUREMENT_TYPE",
                "description": "",
                "name": "Measurement type"
              },
              "name": "Area"
            },
            "name": "Acre",
            "symbol": "ac"
          },
          "value": 0.5
        },
        "isMajorCrop": true,
        "cropType": "CROP_TYPE.MAIN",
        "harvestStatus": "HARVEST_STATUS.PENDING",
        "harvestStartDateTime": null,
        "harvestCompleteDateTime": null,
        "appCreatedAt": "1780000000000",
        "appLastModifiedAt": "1780000000000",
        "createdAt": null,
        "lastModifiedAt": null,
        "ppliCropType": "PPLI_CROP_TYPE.PMDS",
        "expectedHarvestDate": "2026-10-15",
        "seedSource": "SEED_SOURCE.OWN",
        "seedVariety": "Variety A",
        "interestedInCropMarketing": false,
        "sowingDate": "2026-06-05",
        "appId": "7b1e0000-0000-4000-8000-000000000201",
        "syncStatus": "SYNC_PENDING"
      }
    ],
    "portfolioLineItemQuestionResponses": [
      {
        "portfolioLineItemAppId": "5f6c1d2e-0000-4000-8000-00000000a001",
        "id": 0,
        "uuid": "8c2f0000-0000-4000-8000-000000000301",
        "questionId": 12,
        "category": "PMDS",
        "subCategory": "SEED_TREATMENT",
        "questionType": "SINGLE_SELECT",
        "questionCode": "Q_SEED_TREATMENT",
        "questionLabel": "Seed treated?",
        "answerLanguageCode": "en",
        "answerValue": "YES",
        "answerLabel": "Yes",
        "answerText": null,
        "appCreatedAt": "1780000000000",
        "appLastModifiedAt": "1780000000000"
      }
    ]
  }
]
FieldTypeRequiredNotes
[] (PortfolioLineItem)arrayWhole PLI with crops; replaces the local portfolio_portfoliolineitem row (local appId kept).

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 failuresWorker Result.failure(); local edit and error remain.

Source

  • data/src/main/java/org/mindtree/app/agricultor/data/setup/SetupService.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/utils/PortfolioLineItemUpdateWorker.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/rh/PortfolioLineItemPutWithCropChangeRH.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/work/PortfolioLineItemUpdateWorker.kt