Yammer API issue - get groups showing error

微笑、不失礼 提交于 2019-12-25 11:50:23

问题


I am integrating yammer features in our app (web-front-end stack and using Yammer JS SDK). So, I want get all the groups of a login-ed user.

Inorder to get all the groups, I have tried to call the end points in two ways, /groups.json=mine using SDK - resposne showing method not authorised and www.yammer.com/api/v1/groups.json=mine=1 using normal ajax GET request- throwing access control origin issue.

API is perfectly working, while tested using google chrome browser - by disabling web security.

My question is how I can call www.yammer.com/api/v1/API_END_POINTS without cross origin issue using yammer JS SDK or any other technique?

I found an related answer in this Q & A , but still showing error for me.

Error :

XMLHttpRequest cannot load https://www.yammer.com/api/v1/groups.json?mine=1. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://xxx.dev.com' is therefore not allowed access.

Code I have tried after login code :

1# GET Request - return $http.get('https://www.yammer.com/api/v1/groups.json?mine=1')

2# yammer JS SDK -

yam.platform.request({
        url: "groups.json?mine=1",
        method: "GET",
        success: function (group) {
          console.log(group);
        },

        error: function (group) {
          console.error("There was an error with the request.", group);
        }
      });

I have already commented different Q&As for the opinion, but no luck, no one replied.

PS - My all other yammer APIs are working(login, post, message etc), which listed in Yammer REST API Docs, only I am facing problem with APIs hosted in wwww.yammer.com/api/v1, Not api.yammer.com

Thanks in advance


回答1:


You should register an App in Yammer dev console, specify allowed origins, get an API key and send it along with request.

See https://developer.yammer.com/docs/api-requests for more info.



来源:https://stackoverflow.com/questions/44305722/yammer-api-issue-get-groups-showing-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!