Skip to main content

Comments

1 comment

  • VISUI

    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.