API – Batch Requests

The LoanPro API supports sending batch requests, or multiple requests in a single HTTP request.

Sending Batch Requsts

To do batch requests, you will send a POST request to the odata.svc/$batch endpoint. However, unlike normal API communications this request will have a content type of multipart/mixed with a boundary. Responses will be in like manner.

Each section of the request will have the content type and transfer encoding headers, normally application/http and binary respectively. There will then be a blank line followed by the HTTP method (GET,POST,etc) and the URI of the endpoint (you don’t need to specify the domain, but you do need to specify the whole URI).

The response will include the Content-Type, Content-Transfer-Encoding, and Content-ID headers for each section, and will include the HTTP response in the section as well. The HTTP response will hold the status code, Cache-Control and Content-Type headers that the server would give had it been a direct request. It will then have a new line followed by the body of the response.

Below is a sample request for getting flooring customers and loan portfolios.

Request

POST loanpro.simnang.com/api/public/api/1/odata.svc/$batch HTTP/1.1 
Connection: keep-alive
Content-Length: 1175
MaxDataServiceVersion: 3.0
Origin: https://loanpro.simnang.com
Content-Type: multipart/mixed; boundary=batch_7b7b-4d33-39e1
Accept: application/json, text/plain, */*
DataServiceVersion: 2.0
Autopal-Instance-ID: 1
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.8

--batch_7b7b-4d33-39e1
Content-Type: application/http
Content-Transfer-Encoding: binary
 
GET /api/public/api/1/odata.svc/Portfolios?$filter=entityType%20eq%20'Entity.Loan'&all HTTP/1.1
 
 
--batch_7b7b-4d33-39e1
Content-Type: application/http
Content-Transfer-Encoding: binary
 
GET /api/public/api/1/odata.svc/Customers?all&$filter=customerType%20eq%20'customer.type.flooringCustomer' HTTP/1.1

Response

HTTP/1.1 200 OK 
Date: Tue, 02 Aug 2016 16:46:45 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.16
Cache-Control: no-cache
OData-Version: 3
Access-Control-Allow-Origin: *
Access-Control-Max-Age: 86400
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Autopal-Session,Authorization,X-Authorization,Authorization-Mode,Origin,Accept,Content-Type,X-Requested-With,
X-HTTP-Method-Override,Access-Control-Allow-Origin,MaxDataServiceVersion,DataServiceVersion,Autopal-Instance-ID
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS
XSRF-TOKEN: e76nn1fjgptfmtnjni24e7uup6
Transfer-Encoding: chunked
Content-Type: multipart/mixed; boundary=batch_314d514322f619cdf26520764516759bd9b94669


--batch_314d514322f619cdf26520764516759bd9b94669
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Content-ID: </api/1/odata.svc/Portfolios>

HTTP/1.0 200 OK
Cache-Control: no-cache
Content-Type:  application/json

{"d":{"results":[{"__metadata":{"uri":"http://localhost/api/public/api/1/od=
ata.svc/Portfolios(id=3D1)","type":"Entity.Portfolio"},"SubPortfolios":{"__=
deferred":{"uri":"Portfolios(id=3D1)/SubPortfolios"}},"id":1,"title":"Servi=
ce-only Loans","numPrefix":null,"numSuffix":null,"categoryId":3,"entityType=
":"Entity.Loan","created":"/Date(1439482022)/","active":1},{"__metadata":{"=
uri":"http://localhost/api/public/api/1/odata.svc/Portfolios(id=3D2)","type=
":"Entity.Portfolio"},"SubPortfolios":{"__deferred":{"uri":"Portfolios(id=
=3D2)/SubPortfolios"}},"id":2,"title":"Languages","numPrefix":null,"numSuff=
ix":null,"categoryId":1,"entityType":"Entity.Loan","created":"/Date(1440096=
856)/","active":1},{"__metadata":{"uri":"http://localhost/api/public/api/1/=
odata.svc/Portfolios(id=3D5)","type":"Entity.Portfolio"},"SubPortfolios":{"=
__deferred":{"uri":"Portfolios(id=3D5)/SubPortfolios"}},"id":5,"title":"Wes=
t Coast","numPrefix":null,"numSuffix":null,"categoryId":1,"entityType":"Ent=
ity.Loan","created":"/Date(1444669204)/","active":1},{"__metadata":{"uri":"=
http://localhost/api/public/api/1/odata.svc/Portfolios(id=3D7)","type":"Ent=
ity.Portfolio"},"SubPortfolios":{"__deferred":{"uri":"Portfolios(id=3D7)/Su=
bPortfolios"}},"id":7,"title":"East Coast","numPrefix":null,"numSuffix":nul=
l,"categoryId":2,"entityType":"Entity.Loan","created":"/Date(1445981293)/",=
"active":1},{"__metadata":{"uri":"http://localhost/api/public/api/1/odata.s=
vc/Portfolios(id=3D8)","type":"Entity.Portfolio"},"SubPortfolios":{"__defer=
red":{"uri":"Portfolios(id=3D8)/SubPortfolios"}},"id":8,"title":"Alternate =
Loans","numPrefix":null,"numSuffix":null,"categoryId":3,"entityType":"Entit=
y.Loan","created":"/Date(1446588564)/","active":1},{"__metadata":{"uri":"ht=
tp://localhost/api/public/api/1/odata.svc/Portfolios(id=3D9)","type":"Entit=
y.Portfolio"},"SubPortfolios":{"__deferred":{"uri":"Portfolios(id=3D9)/SubP=
ortfolios"}},"id":9,"title":"Pending Inquiry","numPrefix":null,"numSuffix":=
null,"categoryId":2,"entityType":"Entity.Loan","created":"/Date(1446666572)=
/","active":1},{"__metadata":{"uri":"http://localhost/api/public/api/1/odat=
a.svc/Portfolios(id=3D10)","type":"Entity.Portfolio"},"SubPortfolios":{"__d=
eferred":{"uri":"Portfolios(id=3D10)/SubPortfolios"}},"id":10,"title":"This=
 one is definitely over $9000","numPrefix":null,"numSuffix":null,"categoryI=
d":7,"entityType":"Entity.Loan","created":"/Date(1447888867)/","active":1},=
{"__metadata":{"uri":"http://localhost/api/public/api/1/odata.svc/Portfolio=
s(id=3D11)","type":"Entity.Portfolio"},"SubPortfolios":{"__deferred":{"uri"=
:"Portfolios(id=3D11)/SubPortfolios"}},"id":11,"title":"CTEST Portfolio Man=
agement","numPrefix":null,"numSuffix":null,"categoryId":6,"entityType":"Ent=
ity.Loan","created":"/Date(1449611935)/","active":1},{"__metadata":{"uri":"=
http://localhost/api/public/api/1/odata.svc/Portfolios(id=3D12)","type":"En=
tity.Portfolio"},"SubPortfolios":{"__deferred":{"uri":"Portfolios(id=3D12)/=
SubPortfolios"}},"id":12,"title":"KTEST","numPrefix":null,"numSuffix":null,=
"categoryId":10,"entityType":"Entity.Loan","created":"/Date(1450365386)/","=
active":1},{"__metadata":{"uri":"http://localhost/api/public/api/1/odata.sv=
c/Portfolios(id=3D13)","type":"Entity.Portfolio"},"SubPortfolios":{"__defer=
red":{"uri":"Portfolios(id=3D13)/SubPortfolios"}},"id":13,"title":"Just at =
$9000","numPrefix":null,"numSuffix":null,"categoryId":7,"entityType":"Entit=
y.Loan","created":"/Date(1452005589)/","active":1},{"__metadata":{"uri":"ht=
tp://localhost/api/public/api/1/odata.svc/Portfolios(id=3D14)","type":"Enti=
ty.Portfolio"},"SubPortfolios":{"__deferred":{"uri":"Portfolios(id=3D14)/Su=
bPortfolios"}},"id":14,"title":"KTEST 2","numPrefix":null,"numSuffix":null,=
"categoryId":10,"entityType":"Entity.Loan","created":"/Date(1453735306)/","=
active":1},{"__metadata":{"uri":"http://localhost/api/public/api/1/odata.sv=
c/Portfolios(id=3D15)","type":"Entity.Portfolio"},"SubPortfolios":{"__defer=
red":{"uri":"Portfolios(id=3D15)/SubPortfolios"}},"id":15,"title":"Test1","=
numPrefix":null,"numSuffix":null,"categoryId":1,"entityType":"Entity.Loan",=
"created":"/Date(1454000514)/","active":1}],"summary":{"start":0,"pageSize"=
:12,"total":12}}}
--batch_314d514322f619cdf26520764516759bd9b94669
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Content-ID: </api/1/odata.svc/Customers>

HTTP/1.0 200 OK
Cache-Control: no-cache
Content-Type:  application/json

{"d":{"results":[{"__metadata":{"uri":"http://localhost/api/public/api/1/od=
ata.svc/Customers(id=3D39)","type":"Entity.Customer"},"PrimaryAddress":{"__=
deferred":{"uri":"Customers(id=3D39)/PrimaryAddress"}},"MailAddress":{"__de=
ferred":{"uri":"Customers(id=3D39)/MailAddress"}},"Employer":{"__deferred":=
{"uri":"Customers(id=3D39)/Employer"}},"References":{"__deferred":{"uri":"C=
ustomers(id=3D39)/References"}},"PaymentAccounts":{"__deferred":{"uri":"Cus=
tomers(id=3D39)/PaymentAccounts"}},"Phones":{"__deferred":{"uri":"Customers=
(id=3D39)/Phones"}},"CustomFieldValues":{"__deferred":{"uri":"Customers(id=
=3D39)/CustomFieldValues"}},"Documents":{"__deferred":{"uri":"Customers(id=
=3D39)/Documents"}},"CreditScore":{"__deferred":{"uri":"Customers(id=3D39)/=
CreditScore"}},"Loans":{"__deferred":{"uri":"Customers(id=3D39)/Loans"}},"S=
ocialProfiles":{"__deferred":{"uri":"Customers(id=3D39)/SocialProfiles"}},"=
id":39,"customId":null,"mcId":null,"customerType":"customer.type.flooringCu=
stomer","status":"Active","firstName":null,"lastName":null,"middleName":nul=
l,"birthDate":null,"gender":"customer.gender.male","generationCode":"custom=
er.generationCode.none","email":"flooringcustomer@email.com","ssn":null,"dr=
iverLicense":null,"companyName":"Flooring Customer","contactName":"Mr. Floo=
ring Man","customerIdType":"customer.idType.ssn","customerId":null,"creditL=
imit":25000,"accessUserName":"user_5734bac89b9fd","accessPassword":null,"ac=
tive":1,"ofacMatch":0,"ofacTested":1,"hasAvatar":0,"loanRole":null,"created=
":"/Date(1463073480)/","lastUpdate":"/Date(1463073847)/","creditScoreId":7}=
,{"__metadata":{"uri":"http://localhost/api/public/api/1/odata.svc/Customer=
s(id=3D40)","type":"Entity.Customer"},"PrimaryAddress":{"__deferred":{"uri"=
:"Customers(id=3D40)/PrimaryAddress"}},"MailAddress":{"__deferred":{"uri":"=
Customers(id=3D40)/MailAddress"}},"Employer":{"__deferred":{"uri":"Customer=
s(id=3D40)/Employer"}},"References":{"__deferred":{"uri":"Customers(id=3D40=
)/References"}},"PaymentAccounts":{"__deferred":{"uri":"Customers(id=3D40)/=
PaymentAccounts"}},"Phones":{"__deferred":{"uri":"Customers(id=3D40)/Phones=
"}},"CustomFieldValues":{"__deferred":{"uri":"Customers(id=3D40)/CustomFiel=
dValues"}},"Documents":{"__deferred":{"uri":"Customers(id=3D40)/Documents"}=
},"CreditScore":{"__deferred":{"uri":"Customers(id=3D40)/CreditScore"}},"Lo=
ans":{"__deferred":{"uri":"Customers(id=3D40)/Loans"}},"SocialProfiles":{"_=
_deferred":{"uri":"Customers(id=3D40)/SocialProfiles"}},"id":40,"customId":=
null,"mcId":13445,"customerType":"customer.type.flooringCustomer","status":=
"Active","firstName":null,"lastName":null,"middleName":null,"birthDate":nul=
l,"gender":"customer.gender.male","generationCode":"customer.generationCode=
.none","email":null,"ssn":null,"driverLicense":null,"companyName":"Member's=
 Mark","contactName":"Hand Sanitizer","customerIdType":"customer.idType.ssn=
","customerId":null,"creditLimit":30000,"accessUserName":"user_5734e1062eaa=
0","accessPassword":null,"active":1,"ofacMatch":0,"ofacTested":0,"hasAvatar=
":0,"loanRole":null,"created":"/Date(1463083270)/","lastUpdate":"/Date(1465=
584710)/","creditScoreId":null}],"summary":{"start":0,"pageSize":2,"total":=
2}}}
--batch_314d514322f619cdf26520764516759bd9b94669--

To learn more about batch processing, please see Batch Processing (OData Version 3.0).


How did we do?


Powered by HelpDocs (opens in a new tab)