How to insert List of Records using REST API in Acumatica
Hi Team,
I have customized a screen and action button to insert list of records into my custom table. I can able to insert single record at a time, but array list fails. Could you please provide me the correct JSON format for inserting array of records.
I tried the below format but it’s not working.
< { "ScannedId": "14",
"ShipmentNbr": "SDO592042",
"LineNbr": 1,
"Quantity": 1.000000 },
{ "ScannedId": "15",
"ShipmentNbr": "SDO592042",
"LineNbr": 2,
"Quantity": 1.000000 }, ]
Regards,
Ramya
Page 1 / 1
Hi @ramya15
Acumatica Rest API doesn’t support creation of multiple records via single REST request.
Your solution is either make records one by one, or use Screen-based SOAP API (Acumatica wiki)
Hi @ramya15 ,
We can achieve this by changing the logic a little bit. Instead of adding all the data one by one, you can create a single field and structure the JSON as shown below. Then deserialize the data and loop through the data to process multiple records.
Sample JSON:
{ "JsonData": { "value": "{\"CustomerID\":\"AACUSTOMER\",\"MultipleLocations\":n{\"LocationName\":\"Retail Branch\",\"AddressLine1\":\"20 park lane\",\"AddressLine2\":\"\",\"CompanyName\":\"TestCompany\",\"Phone1\":\"7896541236\",\"City\":\"chicago\",\"State\":\"NY\",\"CountryID\":\"US\",\"ZipCode\":\"60033\",\"SetDefault\":\"true\"},{\"LocationName\":\"WholeSale Branch\",\"AddressLine1\":\"20 park lane\",\"AddressLine2\":\"\",\"CompanyName\":\"TestCompany\",\"Phone1\":\"7896541236\",\"City\":\"chicago\",\"State\":\"NY\",\"CountryID\":\"US\",\"ZipCode\":\"60033\",\"SetDefault\":\"true\"}]}" } }
public class JsonData { public string value { get; set; } }
public class MultipleLocations { public JsonData JsonData { get; set; } }
Hi @jinin / @andriitkachenko ,
Thank you for your response. I have found another way to resolve this issue. I exposed the DAC view as a Detail Object Type (Array List) in the Webservice endpoint and send the below JSON structure, it works.