How to load data from API into the Datatable.
Is there any way to load the data into datatable from API . I looked into the
this link but when iam trying to do the same it was not working . It would be helpful if you guys sample working report for this requirement .
Thanks,
Simran
-
In order to return data via an API in Logi you will typically need to set up a connection.REST element in the Settings file, understanding which headers are required for the request, authentication, etc. This example does not require any authentication or KEY
<Connection ID="connAPI" Type="REST" UrlHost="http://catfact.ninja/" />
Then use the DataLayer.REST element to complete the request. JSON data is typically hierarchical, so you will need to understand which node you are returning data from and generally flatten the data using a Flattener element.
<DataTable ID="dt">
<AutoColumns />
<DataLayer AcceptType="application/json" ConnectionID="connAPI" Type="REST" UrlPath="fact">
<Flattener PrependElementNames="True" />
</DataLayer>
</DataTable>
If the API does not require any authentication (like the example), you can simply use a Datalayer.JSON to return the data
<DataTable ID="dt2">
<DataLayer Type="JsonFile" JsonFile="http://catfact.ninja/fact">
<Flattener PrependElementNames="True" />
</DataLayer>
<AutoColumns />
</DataTable>The example you are referencing from Logi is more typical if you want to utilize the returned json data withing javascript code.
0
Please sign in to leave a comment.
Comments
1 comment