1
votes

I'm using rest api to retrieve title, main text etc. of pages on a site on sharepoint online. Problem is when I fetch the xml of a page, there is no reference to the picture that is loaded on the page. I even get the caption but no reference to the picture.

here's an example of the xml I get and the uri I use: https://mysite.sharepoint.com/sites/test/_api/web/lists/pages/items(6)

xml:

<content type="application/xml">
 <m:properties>
<d:FileSystemObjectType m:type="Edm.Int32">0</d:FileSystemObjectType>
<d:Id m:type="Edm.Int32">6</d:Id>
<d:ContentTypeId>0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D00BBA24CC0099910944B5773544989BF2F44BE8E92A</d:ContentTypeId>
<d:Title>Forsikringer</d:Title>
<d:Comments m:null="true" />
<d:PublishingContactId m:null="true" />
<d:PublishingContactEmail m:null="true" />
<d:PublishingContactName m:null="true" />
<d:PublishingContactPicture m:null="true" />
 <d:PublishingPageLayout m:type="SP.FieldUrlValue">
<d:Description>Article Page</d:Description>
<d:Url>https://mysite.sharepoint.com/sites/test-Ucom/_catalogs/masterpage/ArticlePage.aspx</d:Url>
 </d:PublishingPageLayout>
<d:PublishingIsFurlPage m:null="true" />
<d:SeoBrowserTitle m:null="true" />
<d:SeoMetaDescription m:null="true" />
<d:SeoKeywords m:null="true" />
<d:RobotsNoIndex m:null="true" />
<d:PublishingPageContent><p>Vårt forsikringsbyrå sørger for at alle ansatte i Conteso får den behandlingen og oppreisningen som er nødvendig om uhellet er ute. Dersom du sliter med vonde nakke og skuldre etter lange dager foran dataen dekker vår helseforsikring blant annet behandling hos både fysioterapeut og kiropraktor.</p><p> Ønsker du å lese mer om hva vår helseforsikring dekker kan du lese mer om dette i personalhåndboken. </p></d:PublishingPageContent>
<d:ArticleByLine m:null="true" />
<d:ArticleStartDate m:null="true" />
<d:PublishingImageCaption>Vårt forsikringsbyrå sørger for at alle ansatte i Conteso får den behandlingen og oppreisningen som er nødvendig om uhellet er ute.</d:PublishingImageCaption>
<d:FeaturedArticle m:type="Edm.Boolean">true</d:FeaturedArticle>
<d:PntsSmallFeaturedArticle m:type="Edm.Boolean">false</d:PntsSmallFeaturedArticle>
<d:Ingress>??Visste du at i Conteso har alle ansatte personal, reise og helseforsikring i verdensklasse?</d:Ingress>
<d:AllowComments m:type="Edm.Boolean">true</d:AllowComments>
<d:HiddenArticle m:type="Edm.Boolean">false</d:HiddenArticle>
<d:FirstTimePublished m:type="Edm.DateTime">2014-07-17T10:19:57Z</d:FirstTimePublished>
<d:Forfatter>Vikram Rai</d:Forfatter>
<d:Quote m:null="true" />
<d:QuoteBy m:null="true" />
<d:PntsLocation m:null="true" />
<d:PntsTargetGroup m:null="true" />
<d:ID m:type="Edm.Int32">6</d:ID>
<d:Created m:type="Edm.DateTime">2014-09-08T19:13:48Z</d:Created>
<d:AuthorId m:type="Edm.Int32">17</d:AuthorId>
<d:Modified m:type="Edm.DateTime">2014-09-08T19:13:48Z</d:Modified>
<d:EditorId m:type="Edm.Int32">17</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">1c8606fd-2ffd-428b-991b-c9bf49f4d9c6</d:GUID>
 </m:properties>
</content>
1

1 Answers

2
votes

It does not seem possible to retrieve Publishing Image fields using SharePoint REST directly, refer this post for an additional information.

There is a workaround, publishing fields could be retrieved using a separate request to /_api/web/lists/getbytitle('Pages')/items(<item id>)/FieldValuesAsHtml endpoint.

The following example demonstrates how to retrieve PublishingPageImage property from an article page:

/_api/web/lists/getbytitle('Pages')/items(<item id>)/FieldValuesAsHtml?$select=PublishingPageImage

If you are interested in JavaScript solution, please check this answer.