Question

Photo of Bryan Donovan

0

Get Content Type Details using the API

How do you get the 'Item Attributes' list on the Content Type Detail Page from the API? If I ask for expanded attributes, I only see the possible 'Channel Attributes'. Is there a way to ask for the possible/configured Item Attributes using the ContentChannels or ContentChannelTypes endpoints? I'm not looking for the specific attribute values that would be associated with the Content Channel Item. Just the meta information of the possible attributes that are configured. 

  • Photo of Nick Airdo

    0

    Using Mike's REST & OData video along with some interrogation of the Attributes table, I was able to figure this out.  Attributes for a ContentChannelType's ContentChannelItem's (entitytype id = 208 in my environment) are stored in the Attributes table with these references:

    EntityTypeId = 208  (aka Rock.Model.ContentChannelItem in my environment)
    EntityTypeQualifierColumn = 'ContentChannelTypeId'
    EntityTypeQualifierValue = <the Id of the channel type you're looking for>

    So, if I'm programmatically looking for the content channel item attributes for my "Blogs" channel type (Id = 3) my API/OData query would look be:

    http://MYROCKSERVER/api/Attributes/?$filter=EntityTypeId eq 208 
       and EntityTypeQualifierColumn eq 'ContentChannelTypeId' and EntityTypeQualifierValue eq '3'

    If I really only want the attribute "Keys" back I can $select only them:

    http://MYROCKSERVER/api/Attributes/?$filter=EntityTypeId eq 208 
       and EntityTypeQualifierColumn eq 'ContentChannelTypeId' and EntityTypeQualifierValue eq '3'&$select=Key

    Depending on your situation, you may have to set up a REST Key (Admin Tools > Security > REST Keys) and tie it as a user under a controller's REST Security (Admin Tools > Security > REST Controllers) but it does work.  I used the Postman browser extension and was able to get this to work:

    Question1217-PostmanScreenshot.png

    [
       {     "Key": "Summary"   },
       {     "Key": "Image"   }
    ]

    I hope this helps (sorry...better late than never?).