cancel
Showing results for 
Search instead for 
Did you mean: 

Restful Services return type?

erictice
Champ in-the-making
Champ in-the-making
Is the expected behavior of the Restful service to return XML or JSON.  It would appear to be XML, yet all of the documentation I have seen shows examples of JSON.  Is there a way to ask for one versus the other?  Adding the .xml or .json to the end of the query.
8 REPLIES 8

mrogers
Star Contributor
Star Contributor
http://wiki.alfresco.com/wiki/Web_Scripts#Content_Negotiation_and_Response_Formats

It depends upon the implementation of the web script which return types are supported.   First of all there is a the "default" return type that will be returned in the absence of any other guidance.    And then there may be some negotiation of response format,  either through the URL or HTTP ACCEPT headers.

For the repository the service APIs tend to be JSON only, although the CMIS api makes a good job of Atom and JSON.     Share tends to have HTML and XML web scripts.

Adding other return types for all web scripts is on the "todo" list.    The priority at the moment is building out the JSON web scripts to cover the full repository.

erictice
Champ in-the-making
Champ in-the-making
Ok.  Thanks.  I am using the

/alfresco/service/api/node/{store_type}/{store_id}/{id}/children?types={types}&filter={filter?}&skipCount={skipCount?}&maxItems={maxItems?}

to retrieve the children of a space.  I assume this is calling a webscript?

mrogers
Star Contributor
Star Contributor
Yes this is one of the CMIS scripts.

The web script definition file is "children.get.desc.xml" in which the default format is "atomfeed".

I can't see any other return types for this script.

erictice
Champ in-the-making
Champ in-the-making
so setting an Accept application/json would be pointless?

mrogers
Star Contributor
Star Contributor
Yes, from what I can see in the code it will will have no effect.

You may like to try adding your own return format.

erictice
Champ in-the-making
Champ in-the-making
what file contains the return types for that service?  I assume they are embedded in the SDK?

mrogers
Star Contributor
Star Contributor
No, nothing to do with the SDK.

What you need to do is to add a response template file.

erictice
Champ in-the-making
Champ in-the-making
yeah, I found the ftl for atom.  I am looking at it.