API Questions on Kentico API.
Version 6.x > API > REST service - with custom document types View modes: 
User avatar
Member
Member
dburg - 2/22/2012 7:09:52 PM
   
REST service - with custom document types
Hi,
I've been trying to use the REST service to get a filtered list of documents. The documents are a custom document type which inherits from CMS.Article. I have a field called ArticleCategory in my new document type (it is a drop down field, filled with values from a SQL Query).

I have followed the instructions to configure the REST service found here: http://devnet.kentico.com/docs/devguide/index.html?rest_settings.htm

and I can run basic requests such as:
http://localhost/KenticoCMS/rest/content/site/<sitename>/en-us/document/childrenof/GES-Articles/
and
http://localhost/KenticoCMS/rest/content/site/<sitename>/en-us/all/GES-Articles?where=DocumentID=7

but it returns an error when I try to change the where clause to use Article specific fields such as: where=ArticleName='Test Article'

or my to filter by my custom field:
where=ArticleCategory=3

Here is the error message:
Request Error: The server encountered an error processing the request. See server logs for more details.

I'm not sure what server logs I'm supposed to look in.

Does Kentico REST service support filtering by such custom fields? If so, how can I get it to work?


Thanks for you help,
Diana

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/23/2012 2:37:20 AM
   
RE:REST service - with custom document types
Hello Diana,

You need to also specify, which document type will be returned by REST service to tell it, which View has to be used:

/rest/content/site/corporatesite/en-us/all/test?where=gallery='MyGallery'&classnames=custom.asdf


Best regards,
Jan Hermann

User avatar
Member
Member
dburg - 2/23/2012 11:31:37 AM
   
RE:REST service - with custom document types
Hi Jan,
Thank you for your response. I'm new to Kentico, so please excuse me if these are silly question: Where is the view defined? I haven't created any new forms or transformations for my document type, so I'm not sure what is meant by View. I see the term "gallery" in the parameter, but I'm not sure how I determine what gallery my content is in (I just created the articles as child items of the page at /GES-Articles).

I also get the same error if I just put the classnames parameter such as this:
http://localhost/KenticoCMS/rest/content/site/mytestsite/en-us/all/GES-Articles?where=classnames=jti.GESArticle

Thanks,
Diana

User avatar
Member
Member
dburg - 2/23/2012 12:21:42 PM
   
RE:REST service - with custom document types
Okay - I figured it out! The last time, I had the where clause in there with the classnames and forgot the & sign in between. Also I don't need to put the page in there - the following works:

http://localhost/KenticoCMS/rest/content/site/mytestsite/en-us/all/?classnames=jti.gesArticle&where=ArticleCategory=1&columns=ArticleName

Thanks for all your help!
Diana

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/24/2012 2:16:00 AM
   
RE:REST service - with custom document types
Hello,

Yes, that's right. I just answer your question about a View:

A view consists of a stored query accessible as a virtual table in a relational database or a set of documents in a document-oriented database composed of the result set of a query or map and reduce functions. Unlike ordinary tables (base tables) in a relational database, a view does not form part of the physical schema: it is a dynamic, virtual table computed or collated from data in the database. (wikipedia.org)

So a View is located in a database and you can look at it through the SQL Server Management Studio.

Best regards,
Jan Hermann

User avatar
Member
Member
dburg - 2/28/2012 11:35:30 AM
   
RE:REST service - with custom document types
Thanks! I didn't realize you meant a SQL view - thanks for clarifying. Just for future info then, the view is what I would put into the gallery parameter?

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/29/2012 5:13:16 AM
   
RE:REST service - with custom document types
Hello,

No, I've probably confused you with my example before. I was trying to show you, how to get data, when the where condition contains custom field (this custom field was gallery in my case). The View is depended on the classnames parameter.

Best regards,
Jan Hermann