Preview on Device with Data JSON throws exception

89 Views Asked by At

Testing a simple Alexa skill in Authoring tool, with just one text box getting data from "Data JSON" tab throws an exception on doing preview on device. However same works fine when I hard code data directly in the render template.

I have a simple render document with just one text type. And a data JSON having just one property which binds with the text type. It renders fine on the Authoring tool simulator. However, it throws two errors on doing preview on device -
1. There was an error pushing the template to the device.
2. JSON errors found for layout and data integration. Fix errors and view on device again.

enter image description here

If I remove the binding and add the text right in the render document, preview works.

Also, default samples available on authoring tool works like a charm on both simulator and preview on device.

Render document
{ "type": "APL", "version": "1.0", "theme": "dark", "mainTemplate": { "parameters": [ "payload" ], "item": [ { "type": "Text", "color": "#FFFFFF", "text": "${payload.textTitle}" } ] } }

Data JSON
{ "textTitle": "Hello how are you" }

I think I am missing something very basic. This simple example should have worked.

I am previewing it on Echo Show 2nd generation

1

There are 1 best solutions below

1
On

I've been playing around APL and run into this same issue. It seems that the datasource must contain objects, not primitives. So ${payload.titleText} fails some kind of schema check before sending to the device. And when you put it into an object under the datasource, e.g. ${payload.title.text}, no errors!

The following appears to work for me:

 {
  "type": "APL",
  "version": "1.0",
  "theme": "dark",
  "mainTemplate": {
    "parameters": [
      "payload"
    ],
    "item": [
      {
        "type": "Text",
        "color": "#FFFFFF",
        "text": "${payload.title.text}"
      }
    ]
  }
}

and this data:

{
  "title": { "text": "Hello how are you" }
}