【发布时间】:2015-04-03 06:57:20
【问题描述】:
我正在尝试从本地服务器向 Office365 RESTful API 服务发出 ajax GET 请求,但遇到了跨域 HTTPRequest 错误。以下是我的“get-files-at-root”尝试的示例:
$.ajax({
url: 'https://[sharepoint_site]/_api/v1.0/me/files?access_token='+token,
type: 'get',
dataType: 'json',
success: function(data) {
if (success){
success(data);
}
},
error: error
})
我从服务器收到以下响应:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 403.
我已尝试将访问令牌作为标头参数发送:
headers: {'Authorization': 'Bearer '+ token}
但结果相同。
关于我做错了什么有什么想法吗?
(背景:我正在尝试在客户端上创建自己的 Office365“文件选择器”,因为我找不到提供此功能的 OneDrive Business 可用库。)
【问题讨论】:
-
您确定 Sharepoint REST API 支持 CORS?
-
他们现在这样做了!见下文...