下载安卓APP箭头
箭头给我发消息

客服QQ:3315713922

浅谈SharePoint REST上传文件请求403错误怎么办

作者:匿名     来源: Office点击数:526发布时间: 2022-12-04 21:59:27

标签: SharePointRESTSharePoint文件

  浅谈SharePoint REST上传文件请求403错误怎么办最近,需要在SharePoint上传文件到文档库。

  浅谈SharePoint REST上传文件请求403错误怎么办

  最近,需要在SharePoint上传文件到文档库,但是,上传的过程报错了.

  错误代码

  {

  "error": {

  "code": "-2130575251, Microsoft.SharePoint.SPException",

  "message": {

  "lang": "en-US",

  "value": "The security validation for this page is invalid and might be corrupted. Please use your web browser's Back button to try your operation again."

  }

  }

  }

  操作就是调用SharePoint Plus 添加文档

  https://aymkdn.github.io/SharepointPlus/files.html#createFile

  有兴趣的可以看一下这个插件,本来以为是插件的问题,后来发现并不是.

  发现插件在执行这个方法的时候,其实是Call REST Service.

  然后,调用了REST API上传,也是报一样的错误.

  后来发现,是Request Digest token需要刷新一下:

  复制代码

  $.ajax({

  url: _spPageContextInfo.webAbsoluteUrl + "/_api/contextinfo",

  method: "POST",

  headers: { "Accept": "application/json; odata=verbose"},

  success: function (data) {

  $('#__REQUESTDIGEST').val(data.d.GetContextWebInformation.FormDigestValue)

  },

  error: function (data, errorCode, errorMessage) {

  alert(errorMessage)

  }

  });

  复制代码

  执行完上面的代码以后,就可以正常上传文件了.完事儿以后,有想了想为什么,可能是因为根网站集调用同web application下其他网站集吧.

  >>>>>>点击进入office办公软件

赞(10)
踩(0)
分享到:
华为认证网络工程师 HCIE直播课视频教程