API – Custom Forms

Introduction

This article will describe how to pull a custom form from LMS directly with the API.

Pulling a Custom Form with the LoanPro API

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

Initiating the Form Generation

You can try this request yourself on our ReadMe page—an interactive API documentation page which lists each of our requests.

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/935

(Note that "935" in this example is the ID of the loan for which you are generating a form for.)

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

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

{
“0”:3
}

For multiple forms, use something like the next example.

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

Generating multiple forms in this fashion will merge them into a single PDF. If you want them generated as separate PDF’s, you should submit each form separately.

Checking Form Download Status

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_935′ and created gt datetime’2021-10-20 16:47:50’

This endpoint might look a bit odd if you haven't seen one like it before. The important part is the $filter query parameter, which restricts the results to the loan. This endpoint, for instance, restricts the results to a particular form, and those that are created after ('gt', or greater than) a given date. Otherwise, you will receive results from other loans or older forms generated by the same loan.

To learn more about endpoint parameters, read our API – Paginating Results article.

You will receive a standard OData query result. In the result below, you can see the result of 2 forms that were generated because we 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_935”,
        “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_935”,
        “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. It will read, “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, 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)