Search code examples
sharepointodata

Getting lists definition a SharePoint site


I can see all the lists in a project site using <sharepoint site URL>/_vti_bin/ListData.svc/, but how can I get to see all the lists AND their columns? Is there a way of achieving this?


Solution

  • You can't do it in one query. You will need to go through one by one to get the list definition. For example, if you have a list called Calendar you can get the items and the fields by going to <sharepoint site URL>/_vti_bin/listdata.svc/Calendar. It will output the list items and for each entry is a tag called content within which is another tag called m:properties. This includes all the fields for the content type and their values.

    <content type="application/xml">
      <m:properties>
        <d:ContentTypeID>0x010200FD20E8386D889748BDD9444F29251083</d:ContentTypeID>
        <d:Title>Meeting with Bob</d:Title>
        <d:Location>WebEx</d:Location>
        <d:StartTime m:type="Edm.DateTime">2014-11-26T10:00:00</d:StartTime>
        <d:EndTime m:type="Edm.DateTime">2014-11-26T10:30:00</d:EndTime>
        <d:Description>&lt;div&gt;Meeting with Bob&lt;/div&gt;</d:Description>
        <d:AllDayEvent m:type="Edm.Boolean">false</d:AllDayEvent>
        <d:Recurrence m:type="Edm.Boolean">false</d:Recurrence>
        <d:Workspace m:type="Edm.Boolean">false</d:Workspace>
        <d:CategoryValue>Meeting</d:CategoryValue>
        <d:TeamMemberNameId m:type="Edm.Int32">138</d:TeamMemberNameId>
        <d:Id m:type="Edm.Int32">1</d:Id>
        <d:ContentType>Event</d:ContentType>
        <d:Modified m:type="Edm.DateTime">2014-11-26T09:35:12</d:Modified>
        <d:Created m:type="Edm.DateTime">2014-11-26T09:35:12</d:Created>
        <d:CreatedById m:type="Edm.Int32">2990</d:CreatedById>
        <d:ModifiedById m:type="Edm.Int32">2990</d:ModifiedById>
        <d:Owshiddenversion m:type="Edm.Int32">1</d:Owshiddenversion>
        <d:Version>1.0</d:Version>
        <d:Path>/Lists/Calendar</d:Path>
      </m:properties>
    </content>