Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
211 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...