I have created a WebAPI - Write to Database - POST
When I send an array of data, it only takes the first dataset. How to process all the records in the array?
a!localVariables( local!value: cast( 'type!{urn:com:appian:types:YM}XX_WebAPI', a!fromJson(http!request.body) ), a!writeToDataStoreEntity( dataStoreEntity: cons!XX_WEBAPI_TC, valueToStore: local!value, onSuccess: a!httpResponse( statusCode: 200, headers: { a!httpHeader(name: "Content-Type", value: "application/json") }, body: a!toJson( fv!storedValues ) ), onError: a!httpResponse( statusCode: 500, headers: { a!httpHeader(name: "Content-Type", value: "application/json") }, body: a!toJson( { error: "There was an error writing to the data store" } ) ) ))
Sample Data Set:
[ { "Column1": "AA",
"Column2": 1111
},
{
"Column1": "BB",
"Column2": 2222
"Column1": "CC",
"Column2": 3333
}
]
Thanks
Discussion posts and replies are publicly visible
You need to cast the incoming data into a list. See line two.
local!value: cast( 'type!{urn:com:appian:types:YM}XX_WebAPI?list', a!fromJson(http!request.body) ),