1

I'm trying to use Symphony CMS to output its XSL as JSON, for use in the angular phonecat app example from the tutorial. My list view json is output as an array with [{ }] brackets around it. My detail view json is output with only { } around it:

{
 "position": 1,
 "order": 3,
 "total": "1",
 "id": "sunt",
 "sym_id": "21",
 "cat": "back-end",
 "imageUrl": "http://localhost:8080/workspace/images/phones/Nondell-streak-7.0.jpg",
 "name": "Sunt",
 "done": "No",
 "priority": "medium",
 "date-created" : "18 November 2015",
 "date-modified" : "19/11/15 10:41am",
 "date-due" : "18/11/15 2:13pm",
 "snippet": "Quam nihil molestiae"
}

When loading my page the list view loads. When I click on an item the detail view tries to load but I get: SyntaxError: Unexpected token ,. Why? The syntax seems normal to me?

A big problem I am struggling with is that my json is created dynamically with the CMS but no actual files are on the server as far as I know.

Before I was getting the error: Error in resource configuration for action get. Expected response to contain an object but got an array so I made some changes so the list is output as an array, and the single views are output as an object.

My json is generated on localhost:8080/json/{parameter}. The param is 'todos' when not set. So my list view is situated at localhost:8080/json/todos. The param takes the selected object's name, so my detail view would be at localhost:8080/json/foo when I press the link generated by angular.

I hope my question is complete and makes sense :D

  • do you set content-type as application/json on the response? – koox00 Nov 19 '15 at 11:19
  • When I run curl --head localhost:8080/json/foo | grep Content-Type i get text/html When I run curl --head localhost:8080/json/foo | grep Content-Type i get application/json This rewrite rule is in the htacces RewriteRule ^(.*\/?)\.json$ index.php?symphony-page=$1&%{QUERY_STRING} [L] – Aphex_ Nov 19 '15 at 11:29
  • Someone on a chat has commented: "it may be an authentication token. It depend on how you do authentication on your site. Do you need to be logged in to get a respond?" – Aphex_ Nov 19 '15 at 11:31
  • I don't know. but take a look at this might be helpful . symphonyextensions.com/extensions/rest_api ,getsymphony.com/discuss/thread/87298 – koox00 Nov 19 '15 at 11:38
  • Thanks for the extension, I saw the thread :). Still curious what the cause might be of this problem. – Aphex_ Nov 19 '15 at 11:52

Your Answer

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

Browse other questions tagged or ask your own question.