2

I installed Sitecore JavaScript Services Server for Sitecore 9.3 XP 13.0.0 rev. 190924 in a 9.3 instance.

I then created an item under the Home item using the /sitecore/templates/Sample/Sample Item template that comes with Sitecore OOTB.

Then, I attempted to request the URL https://jss2sc.dev.local/sitecore/api/layout/render/jss?item=/sitecore/content/Home/Sample-Item-1&sc_apikey={CD923013-41B7-46C6-B0A9-D726FB003BA7} in the browser and it worked.

I got a response with Status 200 with the following JSON:

{"sitecore":{"context":{"visitorIdentificationTimestamp":637263825029421689,"pageEditing":false,"site":{"name":"website"},"pageState":"normal","language":"en"},"route":{"name":"Sample Item 1","displayName":"Sample Item 1","fields":{"Text":{"value":"<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum euismod placerat tortor, quis faucibus sem mollis mattis. Proin quis blandit erat, eget eleifend mi.</p>"},"Title":{"value":"Sample Item 1"}},"databaseName":"web","deviceId":"fe5d7fdf-89c0-4d99-9aa3-b5fbd009c9f3","itemId":"6e5918f1-74d4-488e-a1e3-37fb73b2a1ec","itemLanguage":"en","itemVersion":1,"layoutId":"14030e9f-ce92-49c6-ad87-7d49b50e42ea","templateId":"76036f5e-cbce-46d1-af0a-4143f9b557aa","templateName":"Sample Item","placeholders":{}}}}

I then created an item using a template I defined and attempted to request that item using the same URL above (but changing the value of the item query string parameter) and got a status 404.

I went back to the Sample Item 1 I had created first that worked and removed all Presentation Details from it and did a full site publish. When I requested it again using the first URL above, I still get a 200 response and I still get the same JSON.

I haven't done any JSS development nor ran jss setup nor ran jss deploy into this 9.3 instance.

So my questions are:

  1. Why is JSS rendering items of template /sitecore/templates/Sample/Sample Item but not of any other template?
  2. Is there anything I can do to configure JSS to also render templates I create?
2

Following some testing locally, the reason you may be getting an Error 404 is when there is no layout set on the item.

So, my test cases were as follows:

1st Test Case

  1. Create an template without any additional fields.
  2. Create an item based on my newly created template.
  3. Access the layout service api.

Outcome: Error 404

2nd Test Case

  1. Create an template without any additional fields.
  2. Create an item based on my newly created template.
  3. Add a layout to the Presentation Details
  4. Access the layout service api.

Outcome: JSON is rendered.

So, to reply to your questions

Why is JSS rendering items of template /sitecore/templates/Sample/Sample Item but not of any other template?

Your template does not have any layout. That is why an error 404 is returned. So, you need to set a layout on the item. It will still work even if you do not have any fields

Is there anything I can do to configure JSS to also render templates I create?

The short answer is no.

One practice that I always follow when implementing sites on JSS is to make all my items that requires rendering inherit the template App Route. So, you can set your layout on the App Route standard values so that all items inherits the same layout.

For you to be able to access the App Route template, you will need to deploy the items to Sitecore.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.