# API Method-getCertificateByRequestID

#### Purpose

Use the “getCertificateByRequestID” method to request for the certificate/pfx/P7B/rekey after the officer manually authorizes the Certificate

#### Type of Method

POST

#### Request URL

[http://www.example.com/emCAServices/rest/getCertificateByRequestID](http://www.example.com/emCAServices/rest/getCertificateByRequestID)

#### Request Input Parameters

<table data-header-hidden><thead><tr><th width="155">Input</th><th width="128">Presence</th><th width="133">Data Type</th><th>Description</th></tr></thead><tbody><tr><td>Parameter</td><td>Presence</td><td>Data Type</td><td>Description</td></tr><tr><td>userName</td><td>M</td><td>String</td><td><p> </p><p>You need to pass username that is registered with emCA for API process.</p></td></tr><tr><td>password</td><td>M</td><td>String</td><td><p> </p><p>You need to pass the password that is registered with emCA for API process.</p></td></tr><tr><td>signature</td><td>M</td><td>String</td><td><p> </p><p>Pass the signed data in section 5 i.e., PKCS#7 data (it should be request id)</p><p>  Signed RequestID</p></td></tr></tbody></table>

#### Sample JSON Object

```
Header: 
			Content-Type : application/json

	Request Body:
	
		{
			"requestData" : "Q/5rvKIZvoMfuZQnysxcGawX4wC1xRttkCHEExreOwUCltgPG0FmsAbEmNHgHvdM2A7Vadyks2IDACydZDRG9rS/uq93IO3KMAyazof7IJXz31c3LiXorwiRksUFOrH2IqYbqI1q88Sf3rnxoTdq8oaOzYB2LoNPh8dZihJyDIR33BccF1Dg/sS/UAwxJ3fjbPzRJpFcqhi2FX1IS8TxyW2PZtPyLtSddyDFxliryGv8RMmVem6NdJYeNHcYo82qHtszdepvIWCi/DLCqs1alR9TcOsKQ8skBTUQY5xfiuONm68zytXBlF+MIAB40Wsw/12zywoCe2z14wqA/mvzF6Jd/Cw3059NfW8FtmBS502ty4l+kSDallVUCSFP9b9Drsh4q/giwT+zHa/SQ3LWCFkjDLaB/OMzMaZfAFwm27/mDB4mSWVMPzMo8CDBvNNNekeV6lSeKSJ7rEbR2JJYIeLzQFp++Dvnp0KZHZu5r+muXAPFCnsDj3MbLrpvbdl3VYKjtDCu0MXi/LX787pStPvr9coMmHTCwja5p7RwI7Ji/nbOnVpT8f2ylx/Rq7vTFRGAqnFmEK5HAkN6Owdf/dKaKUtifXzJqgjYft0NS7uoXbEJWbb4I86AqLhsPbqqN2zlOXZIaYLvkoleo//gAcevv6ZS3jk5rkhueR44ablyv5nhgQ25Fhg5cqu4hxUBOi1MRXk5RpA6RZkaz+DPGSsJJ4+yKzTEnxhUZvnqzeFEf1cvIU3Fx9PLmvrQ50cE28AdNu749WOUyjq/eZCFC1rmY6KyThU4ng49S+iqCrUiIIF+McgjbuVPRvy0M9eYi9HpVOduV7XEI2zrRLpID0ueVwo/j6XePsofLvk/5J/xT9S8Ge6wgVNQzkO47eLi2VEPf5OXRopBaSLFZ1SPIgBVumlSnPgLfdNVOirJjhqMyADZrXgoAw3c+YTqRhsRDAhtPKx90Qtw643eLEi/1ujz9ZxB6yzTvFYnh05eaM+N08QVlEJcS+z84vqnY6/+8746T6Ct/tDrLdFCNVvveSEPVCujbE6LI6pzAnNuHWZoFYoDjANRTDuS8m3LY3mcC24cTJnNTt7a/hF6IsUj0ygfVctkpATXvW9p1m4p6BpYmXFSP6w0nMvKnHd+Uy2R3qykk/1R6YoZbaG9dM3LrAqqAILkYNucL32xZCbSSKX6HIQtZ0WMAfTubYXLsDnAZCLeph1P+fjnkbgrpizkQg==",		
		}		

```

<table data-header-hidden><thead><tr><th width="128">Parameter</th><th width="136">Presence</th><th width="139">Data Type</th><th>Description</th></tr></thead><tbody><tr><td>Parameter</td><td>Presence</td><td>Data Type</td><td>Description</td></tr><tr><td>requestData</td><td>M</td><td>String</td><td><p>All the request input parameters mentioned above should be converted to JSON object and encrypted with AES 256 key shared with you by the emCA team.</p><p>Pass Encrypted JSON Object.</p></td></tr><tr><td>userName</td><td>M</td><td>String</td><td><p> </p><p>You need to pass username that is registered with emCA for API process.</p></td></tr></tbody></table>

**Header Details**

<table data-header-hidden><thead><tr><th></th><th width="116"></th><th width="160"></th><th></th></tr></thead><tbody><tr><td>Key</td><td>Presence</td><td>Value</td><td>Description</td></tr><tr><td>Application / JSON</td><td>M</td><td>Content-Type</td><td>Type of request should be in JSON Format.</td></tr><tr><td>Authentication Key</td><td>M</td><td>emKey</td><td>emKey is an encoded key (Refer section 4 for generating Authentication Key using command prompt).</td></tr></tbody></table>

#### Sample Request data

```
requestData	
		{
			"signature" : "MIAGCSqGSIb3DQEHAqCAMIACAQExDzANBglghkgBZQMEAgEFADCABgkqhkiG9w0BBwGggCSABAVwYXdhbgAAAAAAAKCAMIIDpjCCAo6gAwIBAgIDTEtBMA0GCSqGSIb3DQEBCwUAMHQxJTAjBgNVBAMMHENlcnRpZmljYXRlTWFuYWdlciBSb290IDIwMTYxGDAWBgNVBAoMD2VNdWRocmEgTGltaXRlZDEQMA4GA1UECwwHZW11ZGhyYTESMBAGA1UECAwJQmFuZ2Fsb3JlMQswCQYDVQQGEwJJTjAeFw0xODAxMDMxMjIzNDBaFw0yMDAxMDMxMjIzNDBaMCgxFzAVBgNVBA8MDkF1dGhlbnRpY2F0aW9uMQ0wCwYDVQQDDARyYWNhMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAr7KCKiYzr+qMLctENHdC2fKaXyrQAlshfDBaojnByJdDVknlSfeqjNrYn47MJcG+/UpnA/WD1fg5gRvBIILcyhGKGCLuq4T5pMSbo3YlvcZIQWXp8pmhN4qmoNA35mMmP9ikFuDBIhWEj6NbEo0iUPVDSU0Lkx92+8nLROc+jI+h7Ymr0z2N8X3yWXSxSyH6RvF/Hc4uOb163mSJImd3AM50KfLuflShyU+sRPcuYZMNS9Aq48zLVySpAaHxY6xzi3eYyZWptP68i8P/UmPZEBYLlaaKG2r8RXh6E0pfclTI0rt5a9N3bwpaqig5nmFMUGvatzWjvYm/Mi2ETjXW9wIDAQABo4GMMIGJMAwGA1UdEwEB/wQCMAAwIgYDVR0jAQH/BBgwFoAUgrVRaCBCfAEiYlkr6rtaEbNDgsEwIAYDVR0OAQH/BBYEFCKdNzngYMsrwvlBavT8kukvbPrOMA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pzlhoG8p8iEX2wuXXkNlEFq4sjXBlq3pSDnniomtx3Zz0ncTP/yl6yus8ygUY/Q1O21M2oqIFX0XJ4rIiQRxwT5j40amwI9EQbpSzAAAAAAAA",
" userName" : "username"
 " password" : "password "
 "requestId": "string"	
"applicationId": "string"
“isSignedData”  : “true/false”
			
}

```

#### Process

* When request is received by the emCA service, we will decrypt the request JSON Object with the same AES key that is shared with the client.
* After successful decryption, request JSON object (Signed data (request id) + Username + Password) is retrieved.
* First emCA service will validate username and password and check if the IP Address used for request and registered with the user and are same.
* If it is same then signed data (signature) is validated by trust verification, CRL verification and expiry.
* If validation fails at any point in processing the request, the emCA service will throw error/failure message.

#### Response Parameters

| Parameter               | Data Type             | Description                        |
| ----------------------- | --------------------- | ---------------------------------- |
| <p> </p><p>response</p> | <p> </p><p>String</p> | <p> </p><p>Returns JSON Object</p> |

JSON Object Contains below parameters

<table data-header-hidden><thead><tr><th width="149.33333333333331">Parameter</th><th width="153">Data Type</th><th>Description</th></tr></thead><tbody><tr><td>Parameter</td><td>Data Type</td><td>Description</td></tr><tr><td><p> </p><p> </p><p>status</p></td><td>Srting</td><td><p> </p><p>Returns Status of the request as “Pending” if user has not got the certificate approved from the officer.</p><p>Returns Status of the request as “Rejected” if officer has rejected the certificate</p></td></tr><tr><td> </td><td> </td><td><p>Returns Status of the request as “Success” if certificate is approved by the officer and will get the corresponding certificate</p><p>Returns status of the request as “failure” when authentication fails or unregistered user tries to call the API</p></td></tr><tr><td><p> </p><p> </p><p> </p><p> </p><p>result</p></td><td><p> </p><p> </p><p> </p><p> </p><p>String</p></td><td><p> </p><p>Returns</p><p>In case of Pending: “Request Accepted Successfully but not Processed” message will be displayed.</p><p> </p><p>In case of Rejected: “Reason of the Rejection”</p><p>message will be displayed.</p><p> </p><p>In case of success: “Certificate data based on the type of request” message will be displayed.</p><p>In case of failure: error message will be displayed</p></td></tr><tr><td><p> </p><p>subscriberId</p></td><td><p> </p><p>String</p></td><td><p> </p><p>Return Subscriber ID.</p></td></tr><tr><td><p> </p><p>requestId</p></td><td><p> </p><p>String</p></td><td><p> </p><p>Return request ID when request accepted successfully otherwise return null.</p></td></tr></tbody></table>



#### Response JSON Format

```
Sample:
{
  "status": "Pending",
  "result": "Request Accepted Successfully but not Processed",
  "subscriberId": ”XXX”
  "requestId": null,
  “aliasname”:null
}    

{
  "status": "Rejected",
  "result": "Reason of the Rejection",
  "subscriberId": ”XXX”
  "requestId": null,
  “aliasname”:null
}    

{
  "status": "Success",
  "result": "Certificate data based on the type of request",
  "subscriberId": ”XXX”
  "requestId": null,
  “aliasname”:null
}    
  Failure:
{
  "status": "failure",
  "result":"<Error message>"  
  "subscriberId": ”XXX”
  "requestId": null,
  “aliasname”:null
}    


```

#### Error Messages

| Error Message                     | Description                                                                                  |
| --------------------------------- | -------------------------------------------------------------------------------------------- |
| <p> </p><p>Invalid Request Id</p> | If invalid request id given by user “No data found for request Id” message will be displayed |

&#x20;
