We need this:

  • Visual studio

  • Chrome with the extension json view 

  • Locate the Umbracosettings.config file 

  • A new class file (to save the data from the api) 

  • New Controller based on UmbracoApiController

  • Perhaps a new class file (service) 

  • Rest APi base address  https://via.tt.se/json/v2/releases


First we need to create the necessary classes on our project to match the data from the API. In order to see which properties the api gives, you can use chrome and together with the extension “json view“.

 

Once we have the class with the properties we proceed to create our service class with the methods we need.

 

I created two methods:

  • GetTtData

  • serialized_data

GetTfData gets the data from the api.
serialized_data will format the data to UTF-8 if its necessary.

 

Once we have the data saved on our application we will create our controller that will handle the data we just got from the api. 

 In this controller I create two methods:

  • Import method

  • creatingcontent method.

The first method will get the the necessary data from Umbraco, like get the node that will host our new data and the url for the data and it will invoke our service class previously created.

The second method will generate a new Umbraco page object and populate the properties we already have in the previously created class.

 

Now we need to configure how often the task it will run, and the url that the task will invoke. That we do in the umbracosettings.config file. Please note that the intervals it sets in seconds!

Wait and tada!

We have just imported data from an API and generated Umbraco pages with it!