APIs & services / portfolio-service

Refresh a farmer's current crop plan.

Endpointtoday's app
Call
GET /gateway/portfolio-service/api/v1/portfolios/line-items/ownerEntities/actual/v2?ownerEntityId&ownerEntityType&date
Service
portfolio-service
Features
Crop Actual (portfolio)
When
User opens portfolio screen
Auth
X-SESSIONID set by CoreAPI (dooNowOrThrow)
In the App Service

Use case

Online CoreAPI call (dooNowOrThrow) from PortfolioActivity via IePortfolioRepositoryImpl.fetchCropActualNow when the user asks to pull the current month's crop actuals. The first portfolio's line items are appended to the local portfolio (keeping local geofence file info by titleId) and saved. Returns false when nothing is found; on error the raw response is shown as an error.

Headers

HeaderValueNotes
X-SESSIONID<session token>Set by CoreAPIDefaultImpl.doOperation from the session manager; on 401 the session is invalidated and the call retried once (dooNowOrThrow = 1 retry).
Content-Typeapplication/jsonAlways added by CoreAPI for non-multipart requests.

Parameters

ParamInRequiredExampleNotes
ownerEntityIdqueryYes40001Farmer IE id.
ownerEntityTypequeryYesENTITY_TYPE.IEENTITY_TYPE.BRIDGE_USER when the farmer alias is numeric (cadre-as-owner case).
datequeryYes2026/07/01First day of current month, yyyy/MM/dd.

Request

No body. ownerEntityId, ownerEntityType, date

Response

Example response body (synthetic data)
[
  {
    "owningEntityId": "40001",
    "id": 5001,
    "uuid": "3a9d0000-0000-4000-8000-000000000101",
    "ownerEntityType": {
      "code": "ENTITY_TYPE.IE",
      "refClass": {
        "code": "CLASS.ENTITY_TYPE"
      }
    },
    "portfolioLineItemList": [
      {
        "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>",
        "hasSyncError": false,
        "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"
          }
        ],
        "isSelected": false,
        "isPresentInDifferentCB": false
      }
    ]
  }
]
FieldTypeRequiredNotes
[0].portfolioLineItemList[]arrayAppended to the local portfolio and saved.
other portfoliosarrayIgnored (only first used).

Errors

StatusWhenWhat the app does
401Session token expiredCoreAPI invalidates the session and retries once.
503Service unavailableCoreAPI retries once.
any non-2xxOther failuresResource.error(rawResponse) shown on the portfolio screen.

Source

  • app/src/main/java/org/platformcommons/urvi/datasource/repository/impl/IePortfolioRepositoryImpl.kt
  • app/src/main/java/org/platformcommons/urvi/view/portfolio/IePortfolioViewModel.kt
  • app/src/main/java/org/platformcommons/urvi/view/portfolio/PortfolioActivity.kt