77
Views
12
Comments
Solved
 Expose REST Api with complex data structure

I am beginner to Outsystem. I am exposing a rest Api . In that i am using complex structure i.e. structure inside a structure.

i want to insert the child structure into entity. That child structure contain multiple rows .I assigned that structure to aggregate and used ''for  each' component to insert data but it inserted only the last row.

plz suggest me the better way 

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Nilam,

As per the API method Input parameter structure definition, both EmpBankInfo and EmpBankInst are structure type and entity type record placeholder, it means that at an instance the placeholder can only contain a single record 

If your objective is to feed/pass multiple bank account detail for a single newly created employee, I would suggest you to change the EmpBankInfo placeholder type from structure record type to List type placeholder as implemented in the the attached .oml file


Please refer the attached .oml file


Regards,

Benjith Sam

EmployeesAPIREST.oml
2020-10-30 03-48-28
Nilam Patil

Thanks  Benjith Sam ,

It works. changing the data type of structure to structure List solved the iteration issue.

i appreciate your help.

Thank again.

 

 

2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Nilam,

As per my understanding the implemented approach which you followed is correct for the mentioned objective but I got bit confused in understating this statement -> 'I assigned that structure to aggregate'

If possible could you please share the .oml file with us to get a better understanding of your implementation?


Regards,

Benjith Sam

2020-10-30 03-48-28
Nilam Patil

Thanks for the reply.

i wants to insert all rows of that structure into the entity. to which component i should assign that structure so that i can use 'for each' to iterate all rows. 

EmployeesAPIREST.oml
2023-04-07 07-55-02
Krushna Mantri

Hi Nilam,

I have checked your oml file, in that no need of for each loop to create a single record you just need to put Create or update Emp bank info like below:

Hope it will help you!!

Regards,
Krushna

2020-10-30 03-48-28
Nilam Patil

Krushana Mantri wrote:

Hi Nilam,

I have checked your oml file, in that no need of for each loop to create a single record you just need to put Create or update Emp bank info like below:

Hope it will help you!!

Regards,
Krushna

 

 

  i tried this but only last record inserted. i have 3 rows in bank details structure.


2021-03-18 21-03-15
Benjith Sam
 
MVP

Hi Nilam,

After observing the implementation in the shared .oml file, I assume that using the exposed API action and it's input parameter value, you are trying to create a New Employee Record in the Employee Entity and the related employee's bank account details in the EmpBankInfo entity.

Please refer the attached .oml file


Regards,

Benjith Sam

EmployeesAPIREST.oml
2020-10-30 03-48-28
Nilam Patil

Benjith Sam wrote:

Hi Nilam,

After observing the implementation in the shared .oml file, I assume that using the exposed API action and it's input parameter value, you are trying to create a New Employee Record in the Employee Entity and the related employee's bank account details in the EmpBankInfo entity.

Please refer the attached .oml file


Regards,

Benjith Sam

  i tried this but only last record inserted. i have 3 rows in bank details structure.


json is like 

{

 "Name": "Nil112",

"Email": "nil112@outsystems.com",

"Gender": "Male",

"City": "Linda-a-Velha",

"State": "Lisbon",

"Country": "Portugal",

"Occupation": "OutSystems Community Mascot",

  "EmpBankInst": {

    "empId": 1234567891234567,

    "BankName": "w2w",

    "BranchName": "r2r",

    "AccountNo": "t2t"

  },

   "EmpBankInst": {

    "empId": 35535,

    "BankName": "ww2w",

    "BranchName": "r2rr",

    "AccountNo": "t2tt"

  }

}

 

2021-03-18 21-03-15
Benjith Sam
 
MVP
Solution

Hi Nilam,

As per the API method Input parameter structure definition, both EmpBankInfo and EmpBankInst are structure type and entity type record placeholder, it means that at an instance the placeholder can only contain a single record 

If your objective is to feed/pass multiple bank account detail for a single newly created employee, I would suggest you to change the EmpBankInfo placeholder type from structure record type to List type placeholder as implemented in the the attached .oml file


Please refer the attached .oml file


Regards,

Benjith Sam

EmployeesAPIREST.oml
2020-10-30 03-48-28
Nilam Patil

Thanks  Benjith Sam ,

It works. changing the data type of structure to structure List solved the iteration issue.

i appreciate your help.

Thank again.

 

 

2023-04-07 07-55-02
Krushna Mantri

Hi Nilam,

as per the Sample JSON, you are sending multiple Bank info so the input parameter of API should have a 

list of EMP Bank structure like below

then you can iterate that list and create new Bank Infos like below

hope that will help you, find attached oml for your referencece

Regards,

Krushna

EmployeesAPIREST.oml
2020-10-30 03-48-28
Nilam Patil

Krushana Mantri wrote:

Hi Nilam,

as per the Sample JSON, you are sending multiple Bank info so the input parameter of API should have a 

list of EMP Bank structure like below

then you can iterate that list and create new Bank Infos like below

hope that will help you, find attached oml for your referencece

Regards,

Krushna

 Thanks Krushana, 

It works. changing the data type of structure to structure List solved the iteration issue.

i appreciate your help.

Thank again.

 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.