1
<div ng-app="SharePointAngApp" class="row">
   <div ng-controller="spCustomerController" class="span10">
      <ul ng-repeat="file in files">
        <li><a href="SiteDomainUrl{{file.ServerRelativeUrl}}">{{file.Title}}</a> Category: {{file.Category.Title}} {{file.Category.Order}}</li>
      </ul>
   </div>
</div>


<script>
   var myAngApp = angular.module('SharePointAngApp', ['ngSanitize']);
   myAngApp.controller('spCustomerController', function ($scope, $http) {
     $http({
       method: 'GET',
       url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Footer')/RootFolder/Files?$select=Title,CategoryId,Category/Title,Category/Order&$expand=Category&$orderBy=Title",
       headers: { "Accept": "application/json;odata=verbose" }
     }).success(function (data, status, headers, config) {
       $scope.files = data.d.results;
     }).error(function (data, status, headers, config) {
       console.log("REST Query Error!");
     });
  });
</script>

enter image description here

Why won't the lookup results show?

I don't see my Category lookup field within the results.

Results:

enter image description here

enter image description here

/ListItemsAllFields

<?xml version="1.0" encoding="utf-8" ?> 
- <entry xml:base="https://portal-qa.connect.te.com/sites/ehs/_api/" xmlns="http://www.w3.org/2005/Atom" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml" m:etag=""3"">

<id>Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)</id> 


<category  term="SP.Data.FooterItem" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" /> 
<link  rel="edit" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)" /> 
<link  rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FirstUniqueAncestorSecurableObject" type="application/atom+xml;type=entry" title="FirstUniqueAncestorSecurableObject" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)/FirstUniqueAncestorSecurableObject" /> 
<link  rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/RoleAssignments" type="application/atom+xml;type=feed" title="RoleAssignments" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)/RoleAssignments" /> 
<link  rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/AttachmentFiles" type="application/atom+xml;type=feed" title="AttachmentFiles" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)/AttachmentFiles" /> 
<link  rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ContentType" type="application/atom+xml;type=entry" title="ContentType" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)/ContentType" /> 
<link  rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsHtml" type="application/atom+xml;type=entry" title="FieldValuesAsHtml" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)/FieldValuesAsHtml" /> 
<link  rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesAsText" type="application/atom+xml;type=entry" title="FieldValuesAsText" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)/FieldValuesAsText" /> 
<link  rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/FieldValuesForEdit" type="application/atom+xml;type=entry" title="FieldValuesForEdit" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)/FieldValuesForEdit" /> 
<link  rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/File" type="application/atom+xml;type=entry" title="File" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)/File" /> 
<link  rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Folder" type="application/atom+xml;type=entry" title="Folder" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)/Folder" /> 
<link  rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/ParentList" type="application/atom+xml;type=entry" title="ParentList" href="Web/Lists(guid'39a77f47-1e46-4796-a75f-ba1a94446515')/Items(15)/ParentList" /> 
<title  /> 
<updated>2016-10-11T20:10:06Z</updated> 
- <author>
    <name  /> 
  </author>
- <content type="application/xml">
  - <m:properties>
      <d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType> 
      <d:Id m:type="Edm.Int32">15</d:Id>
      <d:ContentTypeId>0x01010086299210AA67E44FA7FA832663E1BE6B</d:ContentTypeId> 
      <d:Title>HP_ULS_1-26-15</d:Title> 
      <d:URL  m:null="true" /> 
      <d:CategoryId m:type="Edm.Int32">2</d:CategoryId> 
      <d:ID m:type="Edm.Int32">15</d:ID> 
      <d:Created m:type="Edm.DateTime">2016-10-07T16:14:27</d:Created> 
      <d:AuthorId m:type="Edm.Int32">1</d:AuthorId> 
      <d:Modified m:type="Edm.DateTime">2016-10-07T16:14:37</d:Modified> 
      <d:EditorId m:type="Edm.Int32">1</d:EditorId> 
      <d:OData__CopySource  m:null="true" /> 
      <d:CheckoutUserId  m:null="true" /> 
      <d:OData__UIVersionString>1.0</d:OData__UIVersionString> 
      <d:GUID m:type="Edm.Guid">d365a0c3-66fd-4b60-9e1b-7f61c570801c</d:GUID> 
    </m:properties>
  </content>
</entry>
6
  • Change url as below: url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Footer')/RootFolder/Files?select=Title,CategoryId,Category/Title,Category/Order&$expand=Category/Title,Category/Order&$orderBy=Title", Commented Oct 7, 2016 at 12:40
  • I've tried that. That does not work. Commented Oct 7, 2016 at 13:34
  • Have you tried looking in that ListItemAllFields property? Commented Oct 11, 2016 at 20:51
  • @DylanCristy Only the CategoryId is within the 'ListItemAllFields' property. I can't seem to access that either. Commented Oct 12, 2016 at 12:24
  • You may need to explicitly get the list item that is associated with each file in order to access that other metadata. I know that in Powershell or the server object model, if you get an SPFile object, to get at the metadata of the site columns in the doc lib you have to get it like this: SPFile.Item["Field Name"], not SPFile["Field Name"], so there is a subtle difference between a "file" object and it's corresponding list item. Commented Oct 12, 2016 at 12:44

1 Answer 1

1

Thank you @DylanCristy for the push in the right direction. I was missing the '$' before select in the query.

url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('Footer')/items?$select=Title,Category/Title,Category/Order,Category/Column,File/Name,File/ServerRelativeUrl,ContentType/Name$expand=Category/Title,Category/Order,Category/Column,File,ContentType/Name"&$orderby=Category/Column,Category/Order",

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.