RestApi Datasource

Use external data in a OpenContent Template

This data-source is actually read-only and let you get data from an external API.

It need to be configured in the manifest .json

{
 "DataSource": "Satrabel.RestApi",
  "DataSourceConfig": {
    "listUrl": "https://www.example.com/api/services/app/Public/GetItems",
    "detailUrl": "https://www.example.com/api/services/app/Public/GetDetail?id={0}"
  },
 /* ....*/   
}

You can optionally add URLs for Additional Data

you need to provide schema.json, options.json (generated by form builder)

Loading Open Content Data From another DNN Site

You can also load data from another Open Content Module on another DNN site.
To do this, you have to generate an API key on the source module and use the RestApi data source with some specific attributes.

Example Manifest

Please note that in the example below you need to replace some tokens with values before you can use it in your manifest.

[PortalAlias] = your PortalAlias.
So as an example: "www.website.com" or in case of a child portal "www.website.com/childportal"

[APIKEY] = the API key generated on the Source site

[TABID] = TabId of the page the Source module is on

[MODULEID] = ModuleId of the Source module

Also it's a good idea to not allow editing in the "slave" template:

"disableEdit": true

{
   "DataSource": "Satrabel.RestApi",
  "DataSourceConfig": {
    "listUrl": "https://[PortalAlias]/DesktopModules/OpenContent/api/ExternalApi/GetAllItems?apiKey=[APIKEY]&tabId=[TABID]&moduleId=[MODULEID]",
    "detailUrl": "https://[PortalAlias]/DesktopModules/OpenContent/api/ExternalApi/GetItem?apiKey=[APIKEY]&tabId=[TABID]&moduleId=[MODULEID]&id={0}"

  },
  "editWitoutPostback": true,
  "editRole": "",
  "disableEdit": true,
  "Index": true,
 
  "templates": {
    "template": {
      "type": "multiple",
      "title": "Blocks",
      "clientSideData": false,
      "main": {
        "template": "template.hbs",
        
        "schemaInTemplate": true,
        "optionsInTemplate": true,
        "additionalDataInTemplate": true
      }
    }

  }
}

🚧

Please note that depending on you IIS configuration your site might serve JSON file to the client

You can add this to the\a web.config file in the template folder to prevent visitors from guessing the path to your Open Content JSON files and see the configuration.

<system.webServer>
    <staticContent>
            <remove fileExtension=".json" />
    </staticContent>
 </system.webServer>

</configuration>