MOSIP 1.2.0 API endpoints tutorials

Hi @rcsampang ,

We don’t have a proper tutorial as of now. But I will be happy to explain a couple of the APIs here.

API Type 1

If you are looking to check the status of the resident’s packet, then you can use the below resident-service API.

Swagger for Resident Services: (https://{baseURL}/resident/v1/swagger-ui/index.html?configUrl=/resident/v1/v3/api-docs/swagger-config#/resident-controller/getRidStatus))

This API doesn’t need any authentication :slight_smile:

Request URL: https://{baseURL}/resident/v1/rid/check-status

Request Body:

{
  "id": "mosip.resident.checkstatus",
  "version": "v1",
  "requesttime": "2023-06-16T11:45:08.162Z",
  "request": {
    "individualId": "11880117741004320230321171036",
    "individualIdType": "RID"
  }
}

Response Body:

{
  "id": "mosip.resident.checkstatus",
  "version": "v1",
  "responsetime": "2023-06-16T11:46:38.556Z",
  "metadata": null,
  "response": {
    "ridStatus": "PROCESSED"
  },
  "errors": null
}

API Type 2

Now there is another API in the Registration Processor to get the status of the resident’s packet.

Swagger for Registration Processor: (https://{baseURL}/registrationprocessor/v1/registrationstatus/swagger-ui/index.html?configUrl=/registrationprocessor/v1/registrationstatus/v3/api-docs/swagger-config))

This API needs authentication. Hence, you need to get an authentication token with one of the roles specified in registration-processor-default.properties.

mosip.role.registration.getPostexternalstatussearch=REGISTRATION_ADMIN,REGISTRATION_OFFICER,REGISTRATION_SUPERVISOR,RESIDENT

Here the roles supported by the API are REGISTRATION_ADMIN, REGISTRATION_OFFICER, REGISTRATION_SUPERVISOR, or RESIDENT.

For generating the authentication token with the required role, you need to use the auth manager APIs.

Swagger for Auth Manager: (https://{baseURL}/v1/authmanager/swagger-ui/index.html?configUrl=/v1/authmanager/v3/api-docs/swagger-config#/authmanager/clientIdSecretKey)

For getting this token, you need to authenticate using the client credentials, which is having the role RESIDENT, which you can find in keycloak.

Request URL: https://{baseURL}/v1/authmanager/authenticate/clientidsecretkey

Request Body:

{
  "id": "string",
  "version": "string",
  "requesttime": "2023-06-16T11:44:29.563Z",
  "metadata": {},
  "request": {
    "clientId": "mosip-resident-client",
    "secretKey": "<secret from keycloak>",
    "appId": "resident"
  }
}

Response Body:

{
  "id": "string",
  "version": "string",
  "responsetime": "2023-06-16T12:48:32.532Z",
  "metadata": null,
  "response": {
    "status": "Success",
    "message": "Clientid and Token combination had been validated successfully"
  },
  "errors": null
}

Here, in the response header, you will have the authentication token below,

 access-control-allow-credentials: true 
 access-control-allow-headers: Date,Content-Type,Accept,X-Requested-With,Authorization,From,X-Auth-Token,Request-Id 
 access-control-allow-methods: POST,GET,OPTIONS,DELETE,PUT,PATCH 
 access-control-allow-origin: https://api-internal.collab.mosip.net 
 access-control-expose-headers: Set-Cookie 
 authorization: eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI2SkdrUVZUZTVCcXZFeVZRemszUm8xT0hRSkdzZ0x6QVVSaS1za3A1UUMwIn0.eyJleHAiOjE2ODY5NTU3MTIsImlhdCI6MTY4NjkxOTcxMiwianRpIjoiMDI3MDJmODItNWRjNC00MTMyLWEyNGMtMjc5NTIzOGVlZTViIiwiaXNzIjoiaHR0cHM6Ly9pYW0uY29sbGFiLm1vc2lwLm5ldC9hdXRoL3JlYWxtcy9tb3NpcCIsImF1ZCI6ImFjY291bnQiLCJzdWIiOiIwZmUxMmIzYS05NzBjLTQ0NjgtYWQxZS1kOWY4ZmU0NmVkYzAiLCJ0eXAiOiJCZWFyZXIiLCJhenAiOiJtb3NpcC1yZXNpZGVudC1jbGllbnQiLCJhY3IiOiIxIiwicmVhbG1fYWNjZXNzIjp7InJvbGVzIjpbIkNSRURFTlRJQUxfUkVRVUVTVCIsIlBNU19BRE1JTiIsIlJFU0lERU5UIiwiU1VCU0NSSUJFX0FVVEhfVFlQRV9TVEFUVVNfVVBEQVRFX0FDS19HRU5FUkFMIiwiUE1TX1VTRVIiLCJvZmZsaW5lX2FjY2VzcyIsIlBBUlRORVJfQURNSU4iLCJ1bWFfYXV0aG9yaXphdGlvbiIsImRlZmF1bHQtcm9sZXMtbW9zaXAiLCJTVUJTQ1JJQkVfQVVUSEVOVElDQVRJT05fVFJBTlNBQ1RJT05fU1RBVFVTIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsibW9zaXAtcmVzaWRlbnQtY2xpZW50Ijp7InJvbGVzIjpbInVtYV9wcm90ZWN0aW9uIl19LCJhY2NvdW50Ijp7InJvbGVzIjpbIm1hbmFnZS1hY2NvdW50IiwibWFuYWdlLWFjY291bnQtbGlua3MiLCJ2aWV3LXByb2ZpbGUiXX19LCJzY29wZSI6InByb2ZpbGUgaW5kaXZpZHVhbF9pZCBlbWFpbCBpZGFfdG9rZW4gYWRkX29pZGNfY2xpZW50IHVwZGF0ZV9vaWRjX2NsaWVudCIsImNsaWVudEhvc3QiOiIxMC40Mi43LjE0MiIsImVtYWlsX3ZlcmlmaWVkIjpmYWxzZSwiY2xpZW50SWQiOiJtb3NpcC1yZXNpZGVudC1jbGllbnQiLCJwcmVmZXJyZWRfdXNlcm5hbWUiOiJzZXJ2aWNlLWFjY291bnQtbW9zaXAtcmVzaWRlbnQtY2xpZW50IiwiY2xpZW50QWRkcmVzcyI6IjEwLjQyLjcuMTQyIn0.OfXTuYU0g_hOaGIJlrjZifv2Y22TIZWgobbyMOHrwoDIE67S0YdXR8HpGG3YzrFnJ4v6_LQ_HuLY7JMBhEtsnOH7FmPUmljQZYjT56ftkjzfFZfpKR7xs6BpM0p6dSFwi34Jc7_2twXiMAtEYhOernX6jOKkAkD9AJAReyZhTC_rMME0WNurnXsV3-_xX2t1ys-2uUgqs_AT3Bm5TVu-2s5jmfNqjqtlgOdxzF1KfGdrEQKeFeNig9y7ta6Kkg2uZ8qd5QeAaUjCeTp93lgqxMnRIOWSEMqPSzB6cEf6GsqhHJod_MPTcuY1vt8a1_QVptSNge-yvVlt6ATd27873w 
 cache-control: no-cache,no-store,max-age=0,must-revalidate 
 connection: keep-alive 
 content-length: 213 
 content-type: application/json;charset=UTF-8 
 date: Fri,16 Jun 2023 12:48:32 GMT 
 expires: 0 
 pragma: no-cache 
 server: nginx/1.18.0 (Ubuntu) 
 x-content-type-options: nosniff 
 x-envoy-upstream-service-time: 79 
 x-frame-options: SAMEORIGIN 
 x-xss-protection: 1; mode=block 

Now, when you use the Registration Processor API, you need to add the above token to the cookie.

Request URL: https://{baseURL}/registrationprocessor/v1/registrationstatus/packetexternalstatus

Request Body:

{
  "id": "mosip.registration.packet.external.status",
  "version": "1.0",
  "requesttime": "2023-06-16T12:59:50.079Z",
  "request": [
    {
      "packetId": "10001101070000520221112023125"
    }
  ]
}

Response Body:

{
  "response": [
    {
      "packetId": "10001101070000520221112023125",
      "statusCode": "ACCEPTED"
    }
  ],
  "errors": [],
  "id": "mosip.registration.packet.external.status",
  "version": "1.0",
  "responsetime": "2023-06-16T13:07:48.905Z"
}

Hope this will help you. Let me know if you need anything else…

2 Likes