7 Replies Latest reply on Jun 16, 2014 4:14 AM by Kevin.Conaway

    How to Pull name of members with docs I shared with?

    amit.bhonsle

      I want to pull data through Export API.

       

      Use case is to pull list of docs I shared with the name of members shared with.

       

      DOC-1

      Document NameShared byShared with
      DOC-1Amittony, ryan. etc.
      DOC-2Amit

      XYX

       

        • Re: How to Pull name of members with docs I shared with?
          jameswright

          The v3 api's contents endpoint for documents has a 'users' field which represents all the users that can see a document. This field only exists on documents which are not a globally/placable viewable. Couple that field with the author and subject of the document and I think you have everything you need.

           

          I use XQuery and an open source application called BaseX to query jive's v3 endpoints for things like this. Assume you want a csv export, the query below should do the trick:

           

          NOTE: I have bolded the parameters which must be changed. In particular the community uri, login for the api call, and the v3 uri of the user who shared the documents. If you want any sharing users, just remove the author filter from the $apiCall variable...

           

          Hopefully this helps. If you want to try this with BaseX:

           

          1) Install BaseX (Open source and free)

          2) Launch the BaseX GUI.

          3) Copy the script below into the Editor Pain

          4) Change the variables mentioned to match your community, login, etc..

          5) Click the "Play" Button

           

          query-jive.png

           

          declare namespace jive = 'http://seu.jive.com';

           

           

          declare function jive:request-template($username as xs:string, $password as xs:string) as node() {

            <http:request username="{$username}" password="{$password}" send-authorization="true" override-media-type="text/plain" method="get" />

          };

           

          declare function jive:process-response($responseBody as xs:string) as node() {

            json:parse(fn:replace($responseBody, "throw.*;\s*", ""))

          };

           

          declare function jive:get-all-items($request-template as node(), $baseURI as xs:string) {

            let $response :=

              jive:process-response(

                http:send-request($request-template, $baseURI)[2])

            return ($response/json/list/_, if($response/json/links/next) then (jive:get-all-items($request-template, $response/json/links/next)) else ())  

          };

           

           

           

          let $destination := 'https://communityUrl.com'

          let $destReq := jive:request-template('loginHere', 'password')

          let $apiCall := '/api/core/v3/contents?filter=author(https://communityUrl.com/api/core/v3/people/2023)'

          return

            let $csv := <csv>

              {

                for $item in jive:get-all-items($destReq, $destination || $apiCall )

                   where $item/users

                   return

                   let $record := $item//users/.. return

                   <record>

                     <documentName>{$record/subject/text()}</documentName>

                     <sharedBy>{$record/author//name/formatted/text()}</sharedBy>

                     <users>{$record/users//name/formatted/text()}</users>

                   </record>

                   

              }

            </csv>

            return csv:serialize($csv, map { "header": "yes"})



          • Re: How to Pull name of members with docs I shared with?

            Hi Amit,

             

            You can do this by using the activity action filter: filter=action(ACTIVITY_SHARE_DOCUMENT)

             

            See Using the V2 Jive Data Export Service (Analytics) for more info