Forum Discussion

b_poplin's avatar
b_poplin
Expert
12 years ago

get a skin.properties value for a lower-level node using REST API

Ultimately, I want to be able to access the skin.properties values via REST API  (restadmin) for category level nodes.

 

I can set up a custom endpoint to access community level skin properties:

${skin.properties.[propertyName]}

 

Question:  What is the syntax for this as a REST API call?

 

Thanks,

Britt

 

  • You can't get the skin via our standard REST API, but like you said, you could get it via an Endpoint (if you don't have the Endpoints tab in studio enabled, contact support and they should be able to turn it on for you).  Here is an example endpoint that might do what you need:

     

    <#assign skinId = http.request.parameters.name.get("skin.id", "") />
    <#if skinId?length gt 0>
      ${skin.set(skinId)}
    </#if>
    <#assign skinPropertyName = http.request.parameters.name.get("skin.property", "") />
    <#assign singleProperty = (skinPropertyName?length gt 0) />
    <response error="false">
      <skin>
        <skin-properties>
        <#list skin.properties?keys as property>
          <#if !singleProperty || property == skinPropertyName>
          <#assign skinPropertyValue = skin.properties[property] />
    <#-- replace commas with blank strings since they should only show up in skin properties that are all numbers --> <#assign skinPropertyValue = skinPropertyValue?string?replace(",","") /> <skin-property name="${property}">${skinPropertyValue}</skin-property> </#if> </#list> </skin-properties> </skin> </response>

     

    You can pass the ?skin.id=<skin id> (where <skin id> is a specfic skin id) to render a specific skin, otherwise it will render the skin that is set for the community.  You can also pass ?skin.property=<skin property (example: skin.property=color_background) to return a single skin property.

  • Excellent, so I will use this syntax via REST API to get the skin id for the category needed:

    http://[server]/restapi/vc/categories/id/[id]/settings/name/skin.id

     

    Then pass that skin id into my endpoint to get the properties I need.

     

    Thanks.

3 Replies

  • VenkS's avatar
    VenkS
    Lithium Alumni (Retired)
    12 years ago

    I don't believe you can get skin properties via the REST API. If you would like to access this externally, you could (as you said) create an endpoint that returns the skin property in an XML format, and then use the endpoint URL. If you would like to access this internally, you could just use the freemarker object.

     

    Could you explain the use case you are trying to achieve?

  • DougS's avatar
    DougS
    Khoros Oracle
    12 years ago

    You can't get the skin via our standard REST API, but like you said, you could get it via an Endpoint (if you don't have the Endpoints tab in studio enabled, contact support and they should be able to turn it on for you).  Here is an example endpoint that might do what you need:

     

    <#assign skinId = http.request.parameters.name.get("skin.id", "") />
    <#if skinId?length gt 0>
      ${skin.set(skinId)}
    </#if>
    <#assign skinPropertyName = http.request.parameters.name.get("skin.property", "") />
    <#assign singleProperty = (skinPropertyName?length gt 0) />
    <response error="false">
      <skin>
        <skin-properties>
        <#list skin.properties?keys as property>
          <#if !singleProperty || property == skinPropertyName>
          <#assign skinPropertyValue = skin.properties[property] />
    <#-- replace commas with blank strings since they should only show up in skin properties that are all numbers --> <#assign skinPropertyValue = skinPropertyValue?string?replace(",","") /> <skin-property name="${property}">${skinPropertyValue}</skin-property> </#if> </#list> </skin-properties> </skin> </response>

     

    You can pass the ?skin.id=<skin id> (where <skin id> is a specfic skin id) to render a specific skin, otherwise it will render the skin that is set for the community.  You can also pass ?skin.property=<skin property (example: skin.property=color_background) to return a single skin property.

  • b_poplin's avatar
    b_poplin
    Expert
    12 years ago

    Excellent, so I will use this syntax via REST API to get the skin id for the category needed:

    http://[server]/restapi/vc/categories/id/[id]/settings/name/skin.id

     

    Then pass that skin id into my endpoint to get the properties I need.

     

    Thanks.