文件夹名称中包含特殊字符时,使用REST API会出错 [英] Using REST API gives error when special chars are in folder name

查看:103
本文介绍了文件夹名称中包含特殊字符时,使用REST API会出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

使用REST API for Sharepoint Online时遇到一个奇怪的问题.我在Linux上使用C ++进行开发.

I have a strange problem using REST API for Sharepoint Online. I use C++ for development, on Linux.

问题:我想递归读取文件夹的内容.当我读取目录_cts时,得到以下URL之一作为答复

The problem: I want to read the content of folders recursively. When I read the directory _cts I get as one of replies the following url

https://[xxx].sharepoint.com/sites/[yyy]/_api/Web/GetFolderByServerRelativePath(decodedurl='/sites/[yyy]/_cts/What's New Notification')

(出于显而易见的原因,域名和站点名称已被[xxx]和[yyy]替换).如果我想阅读"What's New Notification"的内容,我收到错误的文件夹

(for obvious reasons domain name and site name have been replaced by [xxx] and [yyy]). If I want to read the contend of "What's New Notification" folder I get error

The expression "web/getfolderbyserverrelativeurl('_cts/What's New Notification')" is not valid.

即使我使用而不是,我也会遇到相同的错误新增功能通知_cts目录的调用也返回该名称

I get the same error even if I use instead of  What's New Notification the name which is also returned by the call of reading the _cts directory

What%27s%20New%20Notification

如何读取此文件夹的内容?问题在于如何使用REST API来转义'char.

How can I read the content of this folder? The problem is how the ' char should be escaped using REST API.

谢谢

推荐答案

这里是一种解决方法,供您参考.

通过过滤器获取商品ID,例如:

/sites/Team/_api/Web/lists/getbytitle('MyDoc') /Items?

/sites/Team/_api/Web/lists/getbytitle('MyDoc')/Items?


select = id,FileLeafRef&
select=id,FileLeafRef&


filter = startswith(FileLeafRef,'What')
filter=startswith(FileLeafRef,'What')

然后通过以下方式获取文件夹文件:

/sites/Team/_api/Web/lists/getbytitle('MyDoc') /Items(4)/folder/files

最好的问候,


这篇关于文件夹名称中包含特殊字符时,使用REST API会出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆