前言
最近,有个需求,想要获取Image类型的列进行展示
正文
使用的REST API如下,img是Image列的列明,测试发现还区分大小写
_api/Web/Lists/getbytitle('ListName')/Items(ItemId)?$select=img
请求返回的正文,如下:
{"d": {"__metadata": {"id": "780fc159-2a13-4086-80c8-5a4bdf386d59","uri": "https://linyus.sharepoint.com/sites/sitename/_api/Web/Lists(guid'1c28c0d3-9076-42bc-bd79-8b91170b3ac9')/Items(ItemId)","etag": "\"ItemId\"","type": "SP.Data.ListNameListItem"},"img": "{\"fileName\":\"Reserved_ImageAttachment_[3]_[img][8]_[Picture1][1]_[1].png\"}"} }
因为返回的是相对路径,所以需要特别处理下,这里是重点,需要拼成如下格式,然后进行渲染就好了。
https://linyus.sharepoint.com/sites/sitename/Lists/ListName/attachments/ItemId/Reserved_ImageAttachment_[3]_[img][8]_[Picture1][1]_[1].png