How to generate cards using external JSON url?

Hello,
I need to consume JSON and generate cards. Instead of hardcoding JSON in the AppData section, I need to use JSON available at an external URL.

I can access this JSON like this (here it is called on applicationOpen event):

The question is, how can I bind it to cards so that they would be generated using this JSON?
Screenshot 2020-11-08 at 18.37.28

Hi Maxim!

It looks like you’re trying to get external data into your application, but you’re running into problems with application.data. What you’re seeing is a result of the fact that application.data is only meant to be used for static data that is shipped with the application (like configuration information, canned demo/poc data, etc…), not for dynamic data accessed at runtime. In addition, we aren’t currently supporting external data requests like XMLHttpRequest() directly from the client application logic.

The best-practice approach to accomplishing what you’re trying to do securely with Skylight looks something like this:

  • You’ll be working with users’ Work Sessions, so you’ll need to decide whether or not your application is going to allow users to create their own sessions or whether your external system is going to drive the creation/management of work sessions (i.e. from Skylight’s Integration API). Both are possible, allowing for a wide array of different application flows. If a user action should trigger the creation of a session, you can do so using the session.create method within your application logic. Remember that you’ll also want to session.set your new session for the current user in your application logic after it’s been created. If, on the other hand, your use case requires an external system is to be responsible for the creation of sessions, you can make that happen using the Integration API/SDK linked below.
  • Once you’ve decided how sessions get created, you’ll want to save the JSON data for your steps to session.data at runtime for the relevant users’ sessions. This logic will live in a system external to Skylight. This is where building a data connector service that talks to the Skylight API can be helpful if you don’t have the ability to directly integrate the external system you’re working with. If you chose to have the application itself create sessions based on user inputs, you’ll use that service to listen for new session creation events over MQTT, get your JSON, and save it to that session’s data using the Skylight API. If you chose to manage sessions externally, then your logic would both create sessions for various users and save the relevant data to those users.
  • Your application’s views/cards will bind to session.data (rather than application.data as you have it now) so that your users’ UI reflects the live data. As users interact with their sessions’ data, the data connector you’ve written (or the external system of record if you integrated directly) will receive updates of each change, allowing you to write data back to the integrated systems to track the status of work, coordinate with other users’ data, etc…

For more information on creating/managing sessions from the application itself, you can check out the documentation on the Skylight Scripting API

For info on building the integration logic we provide a helpful SDK that wraps the REST/MQTT APIs (currently C# is supported, with more languages on the way) that you can use to interact with the underlying REST/MQTT API to create server-side integrations with external data sources.

Let me know if any of that is unclear and could use some further clarification!

Cheers,
Jeff