Retrieve Publishing image field with Sharepoint 2013 REST Api / CSOM

后端 未结 4 823
忘掉有多难
忘掉有多难 2021-02-06 01:25

We\'re using the Sharepoint 2013 REST API to get all news items from the Sharepoint. We made a custom ContentType \'Newsitem\' with several properties including a Publishing Ima

4条回答
  •  温柔的废话
    2021-02-06 02:04

    function LoadArticle(item) {
      return GetPublishingPageImage(item, ["DCCAIContentImage"]).then(function(
        pub
      ) {
        for (var property in pub.d) {
          if (property == "__metadata") continue;
          item.DCCAIContentImage(pub.d[property]);
        }
      });
    }
    
    function GetPublishingPageImage(curItem, publishingProperties) {
      var query = "/FieldValuesAsHtml?$select=" + publishingProperties;
    
      //debugger;
      var endpointUri = curItem["__metadata"].uri + query;
      //      var endpointUri = curItem.__metadata().uri + query;
    
      return $.ajax({
        url: endpointUri,
        type: "GET",
        processData: false,
        contentType: "application/json;odata=verbose",
        headers: {
          Accept: "application/json;odata=verbose"
        }
      }).then(function(response) {
        return response;
      });
    }
    

提交回复
热议问题