API – Loan Portfolios
Introduction
This article explains how to assign loans to a portfolio or subportfolio as well as remove them. You can assign loans to portfolios in the UI, but this article shows how to do so with the API.
Assigning a Portfolio or SubPortfolio
To assign a loan to a portfolio or a group of portfolios, send a PUT request to the URL of the loan you are assigning. For example, if you have a loan id 123 the endpoint would be the following:
PUT https://loanpro.simnang.com/api/public/api/1/odata.svc/Loans(123)
Below is a sample payload:
{
"Portfolios": {
"results": [
{
"__metadata": {
"uri": "/api/1/odata.svc/Portfolios(id=7)",
"type": "Entity.Portfolio"
}
}
]
},
"SubPortfolios":{
"results":[
{
"__metadata":{
"uri": "\/api\/1\/odata.svc\/Portfolios(id=1)",
"type": "Entity.SubPortfolio"
}
}
]
}
}
- __metadata – The metadata for the portfolio. (Change the "id" parameter in the "uri" string to the id of the portfolio in the tenant settings)
- type – should be set to "Entity.Portfolio"
If you wish to assign multiple portfolios/subportfolios, simply add a new object to the "results" array for each portfolio/subportfolio to which you want to assign the loan.
Here's an example of what that would look like. Simply add the following to the "results" array for portfolios:
{
"__metadata": {
"uri": "/api/1/odata.svc/Portfolios(id=2)",
"type": "Entity.Portfolio"
}
}
To add multiple subportfolios, simply change the entity type to be "type": "Entity.SubPortfolio".
Removing a Portfolio or Subportfolio
Send the same PUT request to the loan you wish to remove from a portfolio or subportfolio.
PUT https://loanpro.simnang.com/api/public/api/1/odata.svc/Loans(123)
Sample payload:
{
"Portfolios": {
"results": [
{
"__metadata": {
"uri": "/api/1/odata.svc/Portfolios(id=7)",
"type": "Entity.Portfolio"
},
"__destroy":true
}
]
},
"SubPortfolios":{
"results":[
{
"__metadata":{
"uri": "\/api\/1\/odata.svc\/Portfolios(id=1)",
"type": "Entity.SubPortfolio"
},
"__destroy":true
}
]
}
}
- __metadata – The metadata for the portfolio. (Change the "id" parameter in the "uri" string to the id of the portfolio in the tenant settings)
- type – should be set to "Entity.Portfolio"