Document Tree as JSOn

Chetan Sharma asked on September 16, 2014 19:16

Hi,

Is there any way to return partial or entire CMS tree as json in the same order it appear in JSON.

e.g - A - B - B1 - B2 - B3 - C - C1 - C2 - A1 ....

I know how to return a json for a particular document types. What I need is t return entire subtree as json in a way that A will contain B and B1 subpart of json will contains B1, B2, B3. C will be at same level as B is and so on.

Regards Chetan

Correct Answer

Brenden Kehren answered on September 16, 2014 22:58

Are you using the RESTful services offered with Kentico out of the box? If so, you should be able to use ?Where=NodeLevel, NodeOrder, NodeName

0 votesVote for this answer Unmark Correct answer

Recent Answers


Chetan Sharma answered on September 16, 2014 23:20

Thanks Brenden,

Well thats the approach I would like to take. The only doubt have is, if REST service will preserve the order of tree as a json.

I tried accessing this via rest service /rest/cms.country?format=json and got this error

IIS specified authentication schemes 'IntegratedWindowsAuthentication, Anonymous', but the binding only supports specification of exactly one authentication scheme. Valid authentication schemes are Digest, Negotiate, NTLM, Basic, or Anonymous. Change the IIS settings so that only a single authentication scheme is used.

Do you have any idea about this? I am sure we wont be able to delete IntegratedWindowsAuthentication from our authentication mode.

Regards Chetan

1 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on September 17, 2014 02:27

You haven't correctly setup or configured the RESTful service in Kentico. Take a look at the link I sent initially and it has the info in there to properly configure authentication. If you set the ?OrderBy=NodeLevel,NodeOrder,NodeName your order should be the same as in the content tree. My mistake in the previous post for stating the WHERE clause

1 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on September 17, 2014 03:44

Yes, I reached out to our network team to figure out this. For some reason, the formatting of Node which I wanted didn't appear after I saved my question.

I want this structure

  • A
    • B
      • B1
      • B2
      • B3
    • C
      • C1
      • C2
      • C3

So if this is the structure of my tree, is there any api that can return my tree in json where A contains B & C at top level. And, B contains B1, B2, B3 in a Nested json. Similarly B & C will be nested in A

I hope I am clear now.

Regards Chetan

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.