APIs & services / asset-service

Post a comment on an endorsement.

Endpointtoday's app
Call
POST /gateway/asset-service/api/v1/endorsementComment
Service
asset-service
Features
VO / SHG / Farmer endorsement, Farmer endorsement details
When
Queued sync (ENDORSEMENT_COMMENT)
Auth
X-SESSIONID stamped when queued (CoreAPI dooWithRetry); X-REQUESTID idempotency key
In the App Service

Use case

Posts a comment that a cadre or unit in-charge writes on the Resolve Comments screen against a VO, SHG or farmer endorsement. EndorsementRepositoryImpl.insertComment saves it locally with an ENDORSEMENT_COMMENT ledger entry and triggers sync. EndorsementCommentWorker queues EndorsementCommentEntity.post(). On 2xx, EndorsementCommentPostRH parses the plain-integer id, stores it, closes the ledger, and sends an FCM data message to /topics/urvi_endorsement_comment from the device. On error it retries later.

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.

Request

Example request body (synthetic data)
{
  "id": null,
  "uuid": "c0000000-0000-4000-8000-000000009001",
  "entityType": "ENTITY.TYPE.FARMER",
  "entityId": "880001",
  "entityCode": "IE-880001",
  "postedBy": "Cadre A",
  "timeStamp": 1748772000000,
  "description": "Please verify the land extent.",
  "commentType": null
}
FieldTypeRequiredNotes
idintNoServer id. The POST response (a plain integer) is stored back here.
uuidstringYesClient primary key.
entityType / entityId / entityCodestringYesEntity being commented on (VO, SHG or farmer).
postedBystringNoPII: author display name. The notification query uses "<userId>-notifications".
timeStamplongNoWire name timeStamp (@SerializedName). Epoch ms.
descriptionstringYesFree-text comment from the Resolve Comments screen. PII: may contain farmer details.
commentTypestring|nullNoLocal only. Set to NOTIFICATIONS for rows saved by the notification worker. Serialised on POST.

Response

Example response body (synthetic data)
9001
FieldTypeRequiredNotes
(body)int (plain text)New comment id, saved via updateEndorsementCommentId. If it does not parse as an int, success is ignored and the ledger stays open.

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 (EndorsementCommentPostRH). 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.

Source

  • data/src/main/java/org/mindtree/app/agricultor/data/sync/entity/EndorsementCommentEntity.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/work/EndorsementCommentWorker.kt
  • data/src/main/java/org/mindtree/app/agricultor/data/sync/rh/EndorsementCommentPostRH.kt
  • app/src/main/java/org/platformcommons/urvi/view/endorsements/comment/ResolveCommentsFragment.kt
  • app/src/main/java/org/platformcommons/urvi/datasource/repository/impl/EndorsementRepositoryImpl.kt