yammer js sdk issues

We are experiencing the following error when accessing Yammer API.

JQMIGRATE: jQuery.parseJSON requires a valid JSON string platfor..._sdk.js (line 31) Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://www.yammer.com/api/v1/suggestions.json. This can be fixed by moving the resource to the same domain or enabling CORS.

Ref: Yammer JS SDK — problems with CORS Here, it is said that the issue is resolved. But we are still facing the issue. Please confirm if the issue is resolved.

Best regards, Parameswaran.

Answers:

Answer

When using the Yammer JS SDK you'll need to reference api.yammer.com instead of www.yammer.com/api/v1.

Or better yet, if you want to clean up the url you can omit the protocol, domain, and extras (/api/v1) and include the REST resource (suggestions in your case) and the output format (json). See example below:

yam.getLoginStatus(
  function(response) {


   if (response.authResponse) {
      console.log("logged in");
      yam.platform.request({
        url: "suggestions.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")
    }
  }
);

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.