APIs & services / assessment-service

List assessments for an actor (activity history, certification).

Endpointtoday's app
Call
GET /gateway/assessment-service/api/v1/assessmentInstanceAssesses
Service
assessment-service
Features
Activity Tracker, Certification survey
When
User opens activity history; background data download
Auth
X-SESSIONID set by CoreAPI (dooNowOrThrow)
In the App Service

Use case

Discrepancy: in the assessment library this exact path is a POST, not a GET. AssessmentRepositoryImpl.getPostAssessmentResponseOperation builds POST /gateway/assessment-service/api/v1/assessmentInstanceAssesses carrying one completed assessment (AIA). It is queued with dooWithRetry, with no sync ledger, when the cadre submits the Certification survey (CertificationViewModel) or an activity on Activity History (ActivityHistoryFragment). If the farmer is not yet on the server, an IECreateAIACreateIntegrator links it to the pending farmer create. The read side is GET gateway/assessment-service/api/v1/assessmentInstanceAssesses/assessedForEntityIds/ (library ApiService), used by FetchAssessmentData on Activity History and by FetchIEDataWorker to mark which farmers already have surveys. AssessmentUtil.fetchAIAData (Bridge LTLD /api/assessmentinstance/assessmentinstanceassesse/v2) is not called anywhere. The library used is commons-assessment-urvi-lib:1.0.13-SNAPSHOT, which is not in the local caches; it was reconstructed from commons-assessment-lib-1.0.12-SNAPSHOT, which has the same packages.

Headers

HeaderValueNotes
X-SESSIONID<session id>Stamped by CoreAPI when the queued operation runs (CoreAPIDefaultImpl.doOperation). On a 401 the token is invalidated and the call retried. BaseResponseHandler also refreshes the session after a 500 on a gateway URL (first 5 attempts).
X-REQUESTID<uuid v4>Idempotency key added by the offline queue (OperationManagerImpl). A 409 replaces it with a new UUID. It is removed for multipart requests.
Content-Typeapplication/jsonSet by the HTTP client for JSON bodies.

Parameters

ParamInRequiredExampleNotes
assessedForEntityIdqueryYes880001GET variant (/assessedForEntityIds/) only: list of farmer or user ids.
assessedForEntityTypequeryYesACTOR_TYPE.IEGET variant only.
assessmentInstanceIdqueryYes501GET variant only: list of instance ids (assessments synced via /assessmentinstances/assessment/).

Request

Example request body (synthetic data)
{
  "id": 0,
  "uuid": "aia-0000-4000-8000-000000000001",
  "tenant": "7",
  "assessedForEntityId": "880001",
  "assessedForEntityType": "ACTOR_TYPE.IE",
  "isActive": true,
  "createdAt": 1748859300000,
  "assessmentTakenOn": "2025-06-02",
  "location": null,
  "assessee": {
    "id": 0,
    "actorType": "ACTOR_TYPE.IE",
    "actorId": "880001",
    "aliasId": "ie-uuid-0001",
    "isActive": true,
    "tenant": 7
  },
  "assessor": {
    "id": 0,
    "actorType": "ACTOR_TYPE.BRIDGE_USER",
    "actorId": "1001",
    "isActive": true,
    "tenant": 7
  },
  "assessmentInstance": {
    "id": 501,
    "assessment": {
      "assessmentCode": "CERTIFICATION_2025",
      "assessmentSubType": {
        "code": "ASSESSMENT_SUB_TYPE.CERTIFICATION"
      }
    }
  },
  "aiadefaultResponseList": [
    {
      "id": 0,
      "uuid": "resp-0000-4000-8000-000000000001",
      "isActive": true,
      "tenant": "7",
      "remarks": null,
      "location": null,
      "sectionQuestion": {
        "id": 9101
      },
      "optionId": {
        "id": 77
      },
      "drobjectiveresponseList": [],
      "drsubjectiveresponseList": [
        {
          "id": 0,
          "responseText": "PRODUCT.PADDY:1.0",
          "remarks": null
        }
      ]
    }
  ]
}
FieldTypeRequiredNotes
idintYes0 for a new AIA.
uuidstringNoClient id. Also used as the operation metaJson on Activity History.
assesseeobjectYesactorType ACTOR_TYPE.IE (farmer, aliasId not digits-only) or BRIDGE_USER (the cadre themselves), actorId, aliasId (farmer app uuid), tenant.
assessorobjectYesThe logged-in cadre (BRIDGE_USER, user id).
assessedForEntityId / assessedForEntityTypestringYesFarmer IE id or user id, and its actor type.
assessmentInstanceobjectYesInstance found by sub-type code (certification) or picked activity.
aiadefaultResponseList[]arrayYesOne entry per question: sectionQuestion, optionId (objective answer), drsubjectiveresponseList[].responseText (free text or custom-crop list built from the crop picker), uuid (also used to match attachments).
tenantstringYesTenant id.
createdAt / assessmentTakenOnlong / string (yyyy-MM-dd)YesSubmission time.
location, isActivestring/booleanNoOptional.

Response

Example response body (synthetic data)
{
  "id": 120045,
  "uuid": "aia-0000-4000-8000-000000000001",
  "tenant": "7",
  "assessedForEntityId": "880001",
  "assessedForEntityType": "ACTOR_TYPE.IE",
  "isActive": true,
  "createdAt": 1748859300000,
  "assessmentTakenOn": "2025-06-02",
  "location": null,
  "assessee": {
    "id": 0,
    "actorType": "ACTOR_TYPE.IE",
    "actorId": "880001",
    "aliasId": "ie-uuid-0001",
    "isActive": true,
    "tenant": 7
  },
  "assessor": {
    "id": 0,
    "actorType": "ACTOR_TYPE.BRIDGE_USER",
    "actorId": "1001",
    "isActive": true,
    "tenant": 7
  },
  "assessmentInstance": {
    "id": 501,
    "assessment": {
      "assessmentCode": "CERTIFICATION_2025",
      "assessmentSubType": {
        "code": "ASSESSMENT_SUB_TYPE.CERTIFICATION"
      }
    }
  },
  "aiadefaultResponseList": [
    {
      "id": 0,
      "uuid": "resp-0000-4000-8000-000000000001",
      "isActive": true,
      "tenant": "7",
      "remarks": null,
      "location": null,
      "sectionQuestion": {
        "id": 9101
      },
      "optionId": {
        "id": 77
      },
      "drobjectiveresponseList": [],
      "drsubjectiveresponseList": [
        {
          "id": 0,
          "responseText": "PRODUCT.PADDY:1.0",
          "remarks": null
        }
      ]
    }
  ]
}
FieldTypeRequiredNotes
idintPOST: AssessmentResponseHandler reads the server id from rawResponse and updates the local AIA. AttachmentIntegrator passes it to the dependent attachment uploads.
[] (GET variant)AssessmentInstanceAssesseeEntity[]Saved to the assessment DB. The assessee and assessedForEntityId of each row mark which farmers have completed surveys.

Errors

StatusWhenWhat the app does
401Session expiredCoreAPI invalidates the session id and retries once. If it still fails, the response handler returns TryAgain.LATER and the operation stays in the queue.
409Duplicate X-REQUESTIDSyncQueueProcessor records the request id and swaps in a fresh X-REQUESTID for the next attempt.
4xx/5xx (other)Server rejects or failsonError returns TryAgain.LATER (AssessmentResponseHandler in the assessment library). Each failure is logged in the local error_log table (URL, body, headers). Every 10th attempt (up to attempt 5000) the whole operation is copied to Firestore urvi_sync_log. A 500 on a gateway URL in the first 5 attempts forces a session refresh.
GET non-2xxFetch failsFetchAssessmentData shows the library error state. FetchIEDataWorker leaves the assessment status flags unchanged.

Source

  • app/src/main/java/org/platformcommons/urvi/view/certification/CertificationViewModel.kt
  • app/src/main/java/org/platformcommons/urvi/view/activity_tracker/ActivityHistoryFragment.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/service/FetchIEDataWorker.kt
  • app/src/main/java/org/platformcommons/urvi/utility/AssessmentUtil.kt
  • app/src/main/java/org/platformcommons/urvi/view/pendingsync/ApiOperationUtil.kt
  • jar: ~/.m2/repository/com/platformcommons/android/lib/commons-assessment-lib/1.0.12-SNAPSHOT (AssessmentRepositoryImpl, data/network/ApiService, AssessmentServiceEndPoints) as proxy for commons-assessment-urvi-lib:1.0.13-SNAPSHOT
  • jar: ~/.gradle/caches/.../BRLEARNING-generated-java-api-9.0.0.jar (AssessmentInstanceAssesseAPI, unused path)