Javascript Yammer REST Api从不同页面进行不同调用

Javascript Yammer REST Api从不同页面进行不同调用,javascript,rest,yammer,Javascript,Rest,Yammer,我有一段简单的代码,使用Yammer JavaScript api查找Yammer上用户可用的组,它看起来有点像这样: yam.platform.request({ url: "groups.json?mine=1", method: "GET", success: function (data) { callback(data); }, error: function (error) { console.log(error); }, Response Head

我有一段简单的代码,使用Yammer JavaScript api查找Yammer上用户可用的组,它看起来有点像这样:

yam.platform.request({
 url: "groups.json?mine=1",
 method: "GET",
 success: function (data) {
     callback(data);
 },
 error: function (error) {
     console.log(error);
 },
Response Headers
Cache-Control:no-cache
Connection:keep-alive
Content-Type:application/json; charset=utf-8
Date:Wed, 26 Nov 2014 17:32:42 GMT
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:nginx
Status:429
Transfer-Encoding:chunked
X-Date:1417023162896
X-Runtime:0.032459
X-UA-Compatible:IE=Edge,chrome=1
Response Headers
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:https://my-access-origin.sharepoint.com
Access-Control-Expose-Headers:content-type, network_id, authorization, x-csrf-token, www-authenticate, x-xss-protection, ETag
Cache-Control:max-age=0, private, must-revalidate
Connection:keep-alive
Content-Type:application/json; charset=utf-8
Date:Thu, 27 Nov 2014 12:17:38 GMT
ETag:"123a45b67cd89ef01234ab45cd67ef"
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:nginx
Status:200 OK
Strict-Transport-Security:max-age=31536000; includeSubDomains
Transfer-Encoding:chunked
X-Content-Type-Options:nosniff
X-Date:1417090658344
X-Robots-Tag:none
X-Runtime:0.066098
X-UA-Compatible:IE=Edge,chrome=1
X-XSS-Protection:1; mode=block
})

调用经过仔细包装,因此每个页面请求只发生一次调用,但它似乎完全是在任意基础上成功或失败的。响应如下所示:

yam.platform.request({
 url: "groups.json?mine=1",
 method: "GET",
 success: function (data) {
     callback(data);
 },
 error: function (error) {
     console.log(error);
 },
Response Headers
Cache-Control:no-cache
Connection:keep-alive
Content-Type:application/json; charset=utf-8
Date:Wed, 26 Nov 2014 17:32:42 GMT
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:nginx
Status:429
Transfer-Encoding:chunked
X-Date:1417023162896
X-Runtime:0.032459
X-UA-Compatible:IE=Edge,chrome=1
Response Headers
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:https://my-access-origin.sharepoint.com
Access-Control-Expose-Headers:content-type, network_id, authorization, x-csrf-token, www-authenticate, x-xss-protection, ETag
Cache-Control:max-age=0, private, must-revalidate
Connection:keep-alive
Content-Type:application/json; charset=utf-8
Date:Thu, 27 Nov 2014 12:17:38 GMT
ETag:"123a45b67cd89ef01234ab45cd67ef"
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:nginx
Status:200 OK
Strict-Transport-Security:max-age=31536000; includeSubDomains
Transfer-Encoding:chunked
X-Content-Type-Options:nosniff
X-Date:1417090658344
X-Robots-Tag:none
X-Runtime:0.066098
X-UA-Compatible:IE=Edge,chrome=1
X-XSS-Protection:1; mode=block
或者像这样:

yam.platform.request({
 url: "groups.json?mine=1",
 method: "GET",
 success: function (data) {
     callback(data);
 },
 error: function (error) {
     console.log(error);
 },
Response Headers
Cache-Control:no-cache
Connection:keep-alive
Content-Type:application/json; charset=utf-8
Date:Wed, 26 Nov 2014 17:32:42 GMT
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:nginx
Status:429
Transfer-Encoding:chunked
X-Date:1417023162896
X-Runtime:0.032459
X-UA-Compatible:IE=Edge,chrome=1
Response Headers
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:https://my-access-origin.sharepoint.com
Access-Control-Expose-Headers:content-type, network_id, authorization, x-csrf-token, www-authenticate, x-xss-protection, ETag
Cache-Control:max-age=0, private, must-revalidate
Connection:keep-alive
Content-Type:application/json; charset=utf-8
Date:Thu, 27 Nov 2014 12:17:38 GMT
ETag:"123a45b67cd89ef01234ab45cd67ef"
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:nginx
Status:200 OK
Strict-Transport-Security:max-age=31536000; includeSubDomains
Transfer-Encoding:chunked
X-Content-Type-Options:nosniff
X-Date:1417090658344
X-Robots-Tag:none
X-Runtime:0.066098
X-UA-Compatible:IE=Edge,chrome=1
X-XSS-Protection:1; mode=block
在前一种情况下,我在开发工具的网络面板中看到一条错误消息,如下所示:

yam.platform.request({
 url: "groups.json?mine=1",
 method: "GET",
 success: function (data) {
     callback(data);
 },
 error: function (error) {
     console.log(error);
 },
Response Headers
Cache-Control:no-cache
Connection:keep-alive
Content-Type:application/json; charset=utf-8
Date:Wed, 26 Nov 2014 17:32:42 GMT
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:nginx
Status:429
Transfer-Encoding:chunked
X-Date:1417023162896
X-Runtime:0.032459
X-UA-Compatible:IE=Edge,chrome=1
Response Headers
Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:https://my-access-origin.sharepoint.com
Access-Control-Expose-Headers:content-type, network_id, authorization, x-csrf-token, www-authenticate, x-xss-protection, ETag
Cache-Control:max-age=0, private, must-revalidate
Connection:keep-alive
Content-Type:application/json; charset=utf-8
Date:Thu, 27 Nov 2014 12:17:38 GMT
ETag:"123a45b67cd89ef01234ab45cd67ef"
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"
Server:nginx
Status:200 OK
Strict-Transport-Security:max-age=31536000; includeSubDomains
Transfer-Encoding:chunked
X-Content-Type-Options:nosniff
X-Date:1417090658344
X-Robots-Tag:none
X-Runtime:0.066098
X-UA-Compatible:IE=Edge,chrome=1
X-XSS-Protection:1; mode=block
无法加载XMLHttpRequest . 不 “Access Control Allow Origin”标头出现在请求的服务器上 资源起源是 因此不允许访问。响应的HTTP状态代码为429

这没有意义,原因有两个——首先,请求在两种情况下都完全相同,其次,我收到了429个太多的请求作为状态代码,但有一个明确的报告,即应该设置Access-Control-Allow_origin头。这在我的请求中从未出现过,但在成功的回复中确实出现过


有人能解释一下发生了什么吗?

首先确保您在Yammer注册的应用程序的Javascript源中找到了web url

如果仍然存在相同的问题,则可能是:

这与Yammer rest API限制有关,更多的是429错误

请参考我在这篇帖子上的答案

由于访问控制源,我也面临类似问题。一些api集仅在www.yammer.com上可用,不在api.yammer.com中,SDK使用的是api.yammer.com,其中groups.json api有问题。我发送的请求没有太多,仍然显示此问题。PS-开发人员文档中没有关于此API的文档。我的问答链接: