Question

I've installed Recess:

http://www.recessframework.org/

Configured the database, added a table, generated model and controller.

In video tutorial you can see author uses URI like ../something.json to get JSON results. I generated a profile class so i navigate to ../profile.json, but get an error:

Unable to provide desired content-type. Does the view XXX exist?

Basically what i need is a proper formed Restful JSON service for a use in Ember.js.

I would love it if Recess return JSON without adding .json.

Have anyone of you know how to make it work? How to make a JSON Restful service with Recess properly?

Recess forum is down, so you are only help.

Was it helpful?

Solution

You need to modify the controller class to allow it output data in JSON format

/**
 * !RespondsWith Json, Layouts
 * !Prefix something/
 */

If you want to get rid of adding .json to the request URL - just leave Json as a single possible output:

/**
 * !RespondsWith Json
 * !Prefix something/
 */

See this link for the details

On the other hand, you are able to force the JSON output using Accept: application/json header in your HTTP requests, so no .json word should be added to the request URL. However, you still need to enable the Json output in your controller class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top