JSON data source - rest asset bug?


(Tim Trodd) #1

Matrix Version:

Hi,

I went to use the json data source to take in json results from a REST resource asset and display them as shadow assets but it won’t let me select it within the details of the data source asset… it comes up with

Asset ID #261482 is of type page_rest_resource_js. Only “page_rest_resource”, “page_standard”, “page_asset_listing”, “search_page”, “file”, “text_file”, “js_file” asset types are allowed.

I’m guessing this is a bug from the matrix update of changing the rest resource to being rest resource with js by default and the name part hasn’t been updated on the asset types allowed?

Thanks,

Tim


(David Schoen) #2

I’m not sure if there’s a work around for this, but it has been logged as a bug - https://jira.squiz.net/browse/MATRIX-1631 .


(David Schoen) #3

It should be possible to work around for now by nesting the REST Resource in to a Standard Page and using that in the JSON Data Source instead.


(Tim Trodd) #4

Thanks David! I’ve tested it and it works which is good solution until the bug is fixed/we get an upgrade!

Cheers,
Tim


(David Higley) #5

We’ve recently upgraded to 5.5.3.3 and am encountering precisely this issue, however am getting a Syntax Error when trying the workaround which I’ve interepreted as:

  1. Create a REST Resource asset using a GET to retrieve the remote content
  2. Create a Standard Page asset, delete the WYSIWYG block,add a nested content block and nest the REST resource created above
  3. Set the Standard Page as the Source asset for the JSON data source.

Looking at the Raw Source Data in the JSON data source, the content is being retrieved but isn’t being parsed.

I’ve set the page to use a blank paint layout and totally blank Design (so stripped out all EES and HTML) but Matrix is still adding a

Any ideas on how to solve this?

Thanks


(Tim Trodd) #6

Hi David,

What’s matrix adding in to make it invalid? I think it’s been stripped out in your post.

We used a separate JSON design rather than just a blank design. In the design we have:

<MySource_PRINT id_name="__global__" var="content_type" content_type="application/json" /> 
<MySource_AREA id_name="page_body" design_area="body" cache="1" />

Just to make sure the content type is json and not html.

Tim


(David Higley) #7

Hi Tim and thanks for the tip re. the Design file layout which was a big help

Matrix was adding <div id=“nested_rest_resource_[container id]”> </div> around the nested content which was causing a JSON error when trying to view the raw data, but this was resolved by changing the nested container style to Raw and it’s now working as expected.

Many thanks again, much appreciated!

David


(Tim Trodd) #8

ahh no problem! glad it’s now working. I forgot that the nested asset wraps it in a div automatically.

Tim