4 Replies Latest reply on Nov 18, 2016 3:55 AM by mitchell_

    Make Jive rest api calls from a Jive addon

    mitchell_

      I am trying to get the entitlements the current user has for a group which can be done with get https://domain/api/core/v3/places/118789/entitlements

      and returns something like:

      {   "contentTypes" : [ "document", "discussion", "poll", "project", "video", "update", "event", "idea" ],   "entitlements" : [ "view" ],   "objectType" : "group",   "type" : "entitlement" }
      

       

      However I run into cross-origin issues when trying to do an ajax request and the group returned by the api does not have a getter for the entitlements api.

       

      https://app-cisco-poc.jiveon.com/api/core/v3/places/118789/entitlements

        • Re: Make Jive rest api calls from a Jive addon

          Requests need to be made through the OpenSocial API's instead of JS AJAX/XHR as those requests are made by the server and passed into the open social container. An example of this would be:

           

          How to POST to a Service from a Tile

           

          For accessing our REST API's, I'd recommend using Core instead of relying on our JS API's. You just need the endpoint for what you're trying to get:

           

          osapi.jive.core.get({ 

                    v : "v3", 

                    href : "/v3/places/118789/entitlements", 

                    }).execute(function(response) {}

            • Re: Make Jive rest api calls from a Jive addon
              mitchell_

              Going to need to update this. Believed at first that it was working but then i noticed no matter what i sent through core the response returned was always

               

              {

                   status: 204

              }

               

              even your example does this

              Never anything else, no matter what endpoint i used.

              Example:

              I am now trying to set an inbox message as read.

              Calling

              osapi.jive.core.post({

              v:'v3',

              href: <url from InboxEntry.jive.update>

              })

              returns above and does nothing in every case (i tried trimming the url down to start at /v3 like in your example still no dice)

               

              I even tried using the rest format used in the inbox page

              POST

              https://cisco-poc.jiveon.com/__services/v2/rest/readtracking/ <InboxEntry.jive.collection with the - replaced with a slash>/read

               

              still nothing from core.

               

              What am i doing wrong?

                • Re: Make Jive rest api calls from a Jive addon
                  gopi.gorantala

                  Have you tried adding the following require feature's under ModulePrefs in the app.xml. Once you add them, then the OSAPI feature will be available to the add-on.

                   

                  <Require feature="osapi"/>

                  <Require feature="opensocial-data" />

                  <Require feature="jive-core-v3" />

                  <Require feature="jive-core-v3-resolver" />

                   

                  After this, You can try the following two different approaches

                   

                  osapi.jive.corev3.contents.get({

                     "place": placeUrl

                  }).execute(function (response) {

                   

                  OR

                   

                  osapi.jive.core.get({

                  v: "v3",

                  href: "/api/..."   //here you have to give the rest API path

                  }).execute(function (response) {

                  });