How To Quickly and Easily Get a List of Fields in a SharePoint 2013 List.

This is going to be the first of two short postings, because while they are related, they are also individually interesting. I was looking for some CSOM to work with Ratings in SharePoint 2013 and not finding much in the way of documentation. After deducing that I would have to go a little well-defined CSOM code, and a little "late bound" code, my next problem was to figure out what fields I needed to retrieve. The fields that hold this content are hidden which makes them tough to figure out using the out of the box UI. However you can get this information pretty easily using the REST endpoint. The way to do it is to just enter this in the browser:

https://theSiteName/_api/web/lists/GetByTitle('theListName')/Fields

This gives you a complete XML dump of the list schema. If you're using IE though you will probably not see the Xml, but instead get the ever so useful RSS feed viewer. To get a handle on this quickly I recommend the following:

 

  1. Right-click and select View Source.
  2. Copy everything.
  3. Open up Visual Studio 2012 and add a new Xml document.
  4. Delete the default goo in the document then paste in the Xml from the browser. It will still look like an unformatted jumble of gooey mess.
  5. On the toolbar you should see an item that looks like a document; if you hover over it the tooltip will say something like "Format the whole document (CTRL + K, CTRL + D). Click that - XML happiness ensues.

Once you've formatted the Xml document you can find your field names in the InternalName element. Hope that helps.