通过REST API获取SharePoint文档库中的预览URL。

huangapple go评论61阅读模式
英文:

Get the preview URL in SharePoint Document library via REST API

问题

我正在制作一个自定义网络部件,通过Fetch连接到SharePoint上的文档列表。以下是我用于检索信息的调用:

/_api/web/lists/getByTitle('Documents')/items?$select=EncodedAbsUrl,*,File/Name&$expand=Folder&$expand=File

目前我已经获得了大部分我需要的项目的数据,但我还需要获取将您重定向到文件预览的URL。

文件预览示例

如果可能的话,我不想再进行一次Fetch。是否有任何项目属性可以通过REST API扩展以获取预览URL?

我已经检查了EncodedAbsUrl和ServerRedirectedEmbedUrl的值,但这些并不完全是我心目中的预览URL。

我看到了一个类似于我的问题的问题,尽管我不需要同样的东西,但我也尝试过扩展fetch以接收更多的vti_x005f数据,但仍然找不到预览URL。

类似的问题

使用以下调用:

/_api/web/lists/getByTitle('Documents')/items?$select=EncodedAbsUrl,*,File/Name/Properties/vti_x005f_shortcuturl&$expand=Folder&$expand=File&$expand=Properties

提前谢谢。

英文:

I am making a custom web part that connects to the Documents list on SharePoint via Fetch. This is the call that I use for retrieving information:

/_api/web/lists/getByTitle('Documents')/items?$select=EncodedAbsUrl,*,File/Name&$expand=Folder&$expand=File

Right now I get mostly all the data that I need for all the items, but I just need to also have the URL that redirects you to the preview of the file
Example of file preview

If possible, I don't want to make another fetch, So is there any item property that I could expand to get the preview URL, via REST API?

I checked the values of EncodedAbsUrl and ServerRedirectedEmbedUrl, but these are not exactly the preview URL that I have in mind.

I've seen a similar question to mine, even tho I don't need the same thing I've also tried expanding the fetch to recieve more data of vti_x005f but still, I couldn't find the preview URL

Similar Question

With this one:
/_api/web/lists/getByTitle('Documents')/items?$select=EncodedAbsUrl,*,File/Name/Properties/vti_x005f_shortcuturl&$expand=Folder&$expand=File&$expand=Properties

Thank you in advance,

答案1

得分: 0

Sure, here are the translated parts:

/_api/web/lists/getbytitle('文档')/items?$select=*,FileLeafRef,FileRef
然后用于PDF或Word

absoluteUrl + "/_layouts/15/WopiFrame.aspx?sourcedoc=" + FileRef + "&file=" + FileLeafRef + "&action=default"
对于图像

/sites/Development/Shared%20Documents/Forms/AllItems.aspx?id=/sites/Development/Shared Documents/lehladakh.jpg&parent=/sites/Development/Shared Documents
英文:
 /_api/web/lists/getbytitle('Documents')/items?$select=*,FileLeafRef,FileRef

then use for pdf or word

absoluteUrl + "/_layouts/15/WopiFrame.aspx?sourcedoc=" + FileRef + "&file=" +FileLeafRef + "&action=default"

for images

/sites/Development/Shared%20Documents/Forms/AllItems.aspx?id=/sites/Development/Shared Documents/lehladakh.jpg&parent=/sites/Development/Shared Documents

huangapple
  • 本文由 发表于 2023年7月6日 16:26:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/76626890.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定