如何通过JSON修改SharePoint文件夹的ModifiedDate字段为当前日期
原代码的核心问题
- JSON语法错误:
host、parameters节点缺少外层大括号,节点间未加逗号分隔,不符合JSON规范 - HTTP方法错误:修改操作需用
POST,而非GET - API路径错误:无法直接通过字段ID调用修改,需通过文件夹实体的
ValidateUpdateListItem方法更新 - 请求体格式错误:SharePoint REST API不支持
fileOrFolder.setLastModified这种写法,需遵循官方请求格式
正确的请求代码
{ "host": { "connectionName": "shared_sharepointonline", "operationId": "HttpRequest", "apiId": "/providers/Microsoft.PowerApps/apis/shared_sharepointonline" }, "parameters": { "dataset": "https://splm.sharepoint.com/sites/PresentationsinProgress", "parameters/method": "POST", "parameters/uri": "_api/web/GetFolderByServerRelativeUrl('/sites/PresentationsinProgress/Documents/目标文件夹名称')/ListItemAllFields/ValidateUpdateListItem()", "parameters/headers": { "Accept": "application/json;odata=verbose", "Content-Type": "application/json;odata=verbose" }, "parameters/body": "{ 'formValues': [ { 'FieldName': 'Modified', 'FieldValue': '@{utcNow('yyyy-MM-ddTHH:mm:ssZ')}' } ] }" }, "authentication": "@parameters('$authentication')" }
关键配置说明
- 替换
目标文件夹名称为实际文件夹名;若要修改Documents根文件夹,将路径改为/sites/PresentationsinProgress/Documents parameters/method设为POST,匹配修改操作的HTTP规范uri通过GetFolderByServerRelativeUrl定位目标文件夹,再调用ValidateUpdateListItem方法完成字段更新- 请求头指定
Content-Type和Accept为application/json;odata=verbose,确保API正确解析请求 - 请求体用
utcNow函数生成当前UTC时间(ISO 8601格式),直接赋值给Modified字段
内容的提问来源于stack exchange,提问作者K E
相关产品推荐
相关产品推荐

