Working with Custom Forms in the API

Question: How do I pull a custom form using the LoanPro API?

Answer:

If you are wanting to pull a custom form from the Software directly in the API & do something with it on your side, this article will help you understand how that works.

The process for generating a custom form is an asynchronous job that happens server side on the LoanPro system.  So, for that reason it involves submitting an HTTP request to initiate the generation of the form and then a periodic query to ask LoanPro if the form generation is complete.  Most forms will only take a second or two to generate, but could take longer depending on the size of the form or if multiple forms were generated at once.

To initiate the form generation, you will use the following endpoint.

POST https://loanpro.simnang.com/api/public/api/1/custom.forms/export/PDF/Loan/469

Note that 469 is the ID of the loan for which you want to generate the form.

The payload will just include a list of forms to be generated by the form ID.

For a single form, use something like this. In this case, the custom form with ID 3 will be generated.

{
“0”:3
}

For multiple forms, use something like this. Note that when generating multiple forms in this fashion they will be merged into a single PDF. If you want them generated as separate PDF’s then you should submit each form separately.

{
“0”:3,
“1”:4
}

Then to query whether the form generation is complete, you can use the following OData endpoint. 

GET https://loanpro.simnang.com/api/public/api/1/odata.svc/DataDumps?$filter=entityType eq ‘Entity.CustomForm_469′ and created gt datetime’2015-10-20 16:47:50’

The important part is the $filter query parameter to restrict the results to the loan and custom form and from the time which you submitted the form. Otherwise, you will receive results from other loans or older forms generated by the same loan.

You will receive a standard OData query result. In the result below you can see the result of 2 forms that were generated because I submitted one with a single form, and then one with 2 forms merged.

 {
  “d”: {
    “results”: [
      {
        “__metadata”: {
          “uri”: “https://loanpro.simnang.com/api/public/api/1/odata.svc/DataDumps(id=5)“,
          “type”: “Entity.DataDump”
        },
        “id”: 5,
        “entityType”: “Entity.CustomForm_469”,
        “fileName”: “CustomForm_OH_Bastion_Loan_Doc-2015-10-21.pdf”,
        “url”: “https://s3.amazonaws.com/fandora-temp-files/tenants/520009/forms/CustomForm_OH_Bastion_Loan_Doc-2015-10-21.pdf?X-Amz-Content-Sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJGQGUJA7YYQOD6SQ%2F20151021%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20151021T162234Z&X-Amz-SignedHeaders=Host&X-Amz-Expires=86400&X-Amz-Signature=576aa1fe438f560d11369da7b39e227e3c5e9a929354a652fab447e2a640276b“,
        “status”: “dataDumpProcess.status.complete”,
        “created”: “/Date(1445444552)/”,
        “createUser”: “Temp User”
      },
      {
        “__metadata”: {
          “uri”: “https://loanpro.simnang.com/api/public/api/1/odata.svc/DataDumps(id=6)“,
          “type”: “Entity.DataDump”
        },
        “id”: 6,
        “entityType”: “Entity.CustomForm_469”,
        “fileName”: “CustomForms_merged_2015-10-21-114157.pdf”,
        “url”: “https://s3.amazonaws.com/fandora-temp-files/tenants/520009/forms/CustomForms_merged_2015-10-21-114157.pdf?X-Amz-Content-Sha256=e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAJGQGUJA7YYQOD6SQ%2F20151021%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20151021T164202Z&X-Amz-SignedHeaders=Host&X-Amz-Expires=86400&X-Amz-Signature=f8f1932f19035027e190edbf76012aea53627fe4a08346a1c7a7ba0f2b5c3b63“,
        “status”: “dataDumpProcess.status.complete”,
        “created”: “/Date(1445445717)/”,
        “createUser”: “Temp User”
      }
    ],
    “summary”: {
      “start”: 0,
      “pageSize”: 50,
      “total”: 2
    }
  }
}

What you want to look for is the “status” property, and it should be “dataDumpProcess.status.complete” when the form has completed generating. Additionally, prior to the form being completed the “fileName” and “url” properties will be null. Once the form is generated then you can use the “url” provided to download the PDF from our Amazon S3 cloud storage service.


How did we do?


Powered by HelpDocs (opens in a new tab)