Making REST API calls directly from a Jive app or tile

Version 3

    When you are writing JavaScript in the context of a Jive app or Jive tile, you can use the JavaScript API to perform many operations with your Jive instance. However, there are some situations where you want to directly access the Jive REST API, either because a particular function isn't available from the JavaScript API or you just want direct access to a particular endpoint. In these cases, you can use the following JavaScript API functions to directly access the Jive REST API:

     

    REST API call typeJavaScript function nameExampleNotes
    GET callsosapi.jive.core.get

    Get recent activity (REST API):

    osapi.jive.core.get({
        v:"v3",
        href:"/activities?count=2"
    }).execute(function(response) {
        console.log("Response is: " + JSON.stringify(response));
    });
    
    
    
    POST callsosapi.jive.core.post

    Create a discussion (REST API):

    osapi.jive.core.post({
        "v" : "v3",
        "href" : "/contents",
        "body" : {
            "type" : "discussion",
            "subject" : "My discussion",
            "content" : {
                "type" : "text/html",
                "text" : "This is the content of a discussion created in JS."
            }
        },
    }).execute(function(response) {
        console.log("Response is: " + JSON.stringify(response));
    });
    
    
    
    POST body data can be sent from within the body key.
    PUT callsosapi.jive.core.put

    Update discussion content (REST API):

    osapi.jive.core.put({
        "v" : "v3",
        "href" : "/contents/{CONTENT_ID}",
        "body" : {
            "type" : "discussion",
            "subject" : "My UPDATED discussion",
            "content" : {
                "type" : "text/html",
                "text" : "This is the UPDATED content."
           }
        },
    }).execute(function(response) {
        console.log("Response is: " + JSON.stringify(response));
    });
    
    
    

    PUT body data can be sent from within the body key.

     

    In this example, replace {CONTENT_ID} with the actual ID of the content.

    DELETE callsosapi.jive.core.delete

    Delete content (REST API):

    osapi.jive.core.delete({
        "v" : "v3",
        "href" : "/contents/{CONTENT_ID}",
    }).execute(function(response) {
        console.log("Response is: " + JSON.stringify(response));
    });
    
    
    
    In this example, replace {CONTENT_ID} with the actual ID of the content.

     

    Known limitations:

    • This feature does not work for binary payloads.