I'm trying to make Yammer API request as per instruction here: . When I run this example:
yam.getLoginStatus(
function(response) {
if (response.authResponse) {
console.log("logged in");
yam.platform.request({
url: ".json", //this is one of many REST endpoints that are available
method: "GET",
data: { //use the data object literal to specify parameters, as documented in the REST API section of this developer site
"letter": "a",
"page": "2",
},
success: function (user) { //print message response information to the console
alert("The request was successful.");
console.dir(user);
},
error: function (user) {
alert("There was an error with the request.");
}
});
}
else {
alert("not logged in")
}
}
);
I'm doing that on localhost and I'm getting following error:
"XMLHttpRequest cannot load .json?letter=a&page=2&_=1401954073159. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access."
Any idea how to solve this?
One more thing. I can't specify additional headers in this as this call is executed as 'OPTIONS' not a 'GET' request method.
Hope someone had same issue with Yammer latest API and was able to solve it.
Thanks
I'm trying to make Yammer API request as per instruction here: https://developer.yammer./yammer-sdks/#javascript-sdk. When I run this example:
yam.getLoginStatus(
function(response) {
if (response.authResponse) {
console.log("logged in");
yam.platform.request({
url: "https://www.yammer./api/v1/users.json", //this is one of many REST endpoints that are available
method: "GET",
data: { //use the data object literal to specify parameters, as documented in the REST API section of this developer site
"letter": "a",
"page": "2",
},
success: function (user) { //print message response information to the console
alert("The request was successful.");
console.dir(user);
},
error: function (user) {
alert("There was an error with the request.");
}
});
}
else {
alert("not logged in")
}
}
);
I'm doing that on localhost and I'm getting following error:
"XMLHttpRequest cannot load https://www.yammer./api/v1/users.json?letter=a&page=2&_=1401954073159. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access."
Any idea how to solve this?
One more thing. I can't specify additional headers in this as this call is executed as 'OPTIONS' not a 'GET' request method.
Hope someone had same issue with Yammer latest API and was able to solve it.
Thanks
Share Improve this question asked Jun 5, 2014 at 7:47 eloleoneloleon 1,2542 gold badges11 silver badges18 bronze badges 4- This is sorted, whole JavaScript Origin side on Yammer it is a bit flaky but finally I got it to work – eloleon Commented Jun 5, 2014 at 8:41
- 1 Any hints on how you made it work? Maybe you could answer your own question – pcv Commented Aug 15, 2014 at 8:53
- hey pcv. I've answered this in next answer: 'Actual 'error' has been caused by their bad documentation. REST endpoint is api.yammer./api/ not www.yammer./api'. thanks – eloleon Commented Aug 21, 2014 at 8:06
- hmhm, that didn't work for me. I get the error no matter if I use www.yammer. or api.yammer. – pcv Commented Aug 21, 2014 at 17:15
3 Answers
Reset to default 3Be sure to update your Yammer apps JS Origins to match the environment hostnames that you are testing in.
You can configure those origins at this link here:
https://www.yammer./client_applications
And clicking your application, then clicking "Basic Info".
Use the hostname as "api.yammer." instead of "www.yammer.". I believe documentation needs to be updated and I'll get that updated.
Alternatively, you can use yam.platform.request('users.json')
instead of yam.request('https://api.yammer./api/v1/users.json')
which you don't have to tweak with the hostname.
add your application url to "Javascript Origins" in yammer application basicinfo.