REST API v3 Examples

    Introduction

     

    This document contains REST API v3 examples. Please edit it to add more examples.

     

    Comments are not allowed as issues are better discussed as new threads within Developer.

     

    Replace '$CURL' with 'curl -v -u Username:Password -k --header "Content-Type: application/json" -d' in the examples below.

    CURL='curl -v -u Username:Password -k --header "Content-Type: application/json" -d'

     

    API 3.3 requires a "Content-Disposition:" header with an (empty) "name=" parameter in each part of a multipart request. REST API 3.3 (Jive7c3) multipart upload broken? The examples below will fail with an "We're sorry but a serious error has occurred in the system." error message.

     

    Content Creation

    Create a public document

     

    $CURL '{"content": {"type": "text/html", "text": "<body><p>Here comes the document body.</p></body>"},"subject": "My public document","type": "document"}' "https://sandbox.jiveon.com/api/core/v3/contents"

     

    Create a document in a place

     

    $CURL '{"visibility":"place", "parent":"https://sandbox.jiveon.com/api/core/v3/places/{placeID}", "type":"document", "subject":"My place document", "content":{"type":"text/html","text":"<body><p>Test of document in a place</p></body>"} }' "https://sandbox.jiveon.com/api/core/v3/contents"


    Replace {placeID} with the ID of the place.

     

    Create a private document with tags


    $CURL '{"visibility": "hidden", "content": {"type": "text/html", "text": "<body><p>Here comes the document body.</p></body>"},"subject": "My private document", "tags": [one, two, three] ,"type": "document"}' "https://sandbox.jiveon.com/api/core/v3/contents"


    Create a private document with an attachment

     

    !! Discussions with attachments require JIVE-20794

    curl -v -u Username:Password --header "Content-Type: multipart/form-data; boundary=SNIP" -d $'--SNIP\r\nContent-Type: application/json\r\n\r\n{"type": "document", "subject": "New Document", "content":{ "type": "text/html", "text": "<body><p>Some interesting text</p></body>"}}\r\n--SNIP\r\nContent-Disposition: form-data; filename="filename.txt"\r\nContent-Type: text/html\r\n\r\nCONTENT\r\n--SNIP--\r\n'  "https://sandbox.jiveon.com/api/core/v3/contents"

    !! "filename" and the "Content-Type" of the attachment are required.

     

    Create a public document with an attachment in a space

     

    curl -v -u Username:Password --header "Content-Type: multipart/form-data; boundary=SNIP" -d $'--SNIP\r\nContent-Type: application/json\r\n\r\n{"visibility": "place", "parent": "https://sandbox.jiveon.com/api/core/v3/places/99999", "type": "document", "subject": "New Document", "content":{ "type": "text/html", "text": "<body><p>Some interesting text</p></body>"}}\r\n--SNIP\r\nContent-Disposition: form-data; filename="filename.txt"\r\nContent-Type: text/html\r\n\r\nCONTENT\r\n--SNIP--\r\n'  "https://sandbox.jiveon.com/api/core/v3/contents"

     

    Create a private document with an attachment from a public URL

     

    $CURL '{"visibility": "people", "content": {"type": "text/html", "text": "<body><p>Here comes the document body.</p></body>"},"subject": "My private document with attachment", "type": "document", "attachments": [{ "doUpload": true, "url": "https://community.jivesoftware.com/people/it2000/avatar/46.png" } ] }' "https://sandbox.jiveon.com/api/core/v3/contents"

     

    Create a document with an attachment from a public URL

     

    $CURL '{ "visibility": "place", "content": {"type": "text/html", "text": "<body><p>Here comes the document body.</p></body>"}, "subject": "Document with attachment", "type": "file", "attachments": [ { "doUpload": true, "url": "https://community.jivesoftware.com/people/it2000/avatar/46.png"}], "parent": "https://sandbox.jiveon.com/api/core/v3/places/1234" }' "https://sandbox.jiveon.com/api/core/v3/contents"

    According to Rest v3 File upload to place - 403 forbidden ``"type": "document",´´ does result in a 403 error.

     

    Create a private discussion

     

    $CURL '{"visibility": "people", "content": {"type": "text/html", "text": "<body><p>Here comes the discussion.</p></body>"},"subject": "My private discussion", "tags": [one, two, three], "type": "discussion"}'  "https://sandbox.jiveon.com/api/core/v3/contents"


    Reply to a discussion

     

    $CURL '{ "content": { "type": "text/html", "text": "<body><p>This is a discussion reply</p></body>" }, "type": "message" }' "https://sandbox.jiveon.com/api/core/v3/messages/contents/{contentID}"

     

    Replace {contentID} with the ID of the discussion.

     

    Update the status / Write a microblog

     

    $CURL '{"type": "update", "content": {"type": "text/html", "text": "<body><p>My micro blog update text.</p></body>"} }' "https://sandbox.jiveon.com/api/core/v3/contents"

     

    Direct Messages (DMS)

    Retrieve a list of all DMS

     

    Jive REST API v3.0 &rarr; Inbox service

     

    Mark DMS as (un)read

     

    Jive REST API v3.0 &rarr; DirectMessage service

     

    Retrieval of place IDs (Blog, Group, Space, Project)

     

    The URLs can also be used in browser after manual login. Nothing is posted, a simple HTTP GET works fine. The ID of a place is needed to create content in it.

    https://sandbox.jiveon.com/api/core/v3/places?sort=dateCreatedAsc&filter=type%28blog%29

    https://sandbox.jiveon.com/api/core/v3/places?sort=dateCreatedAsc&filter=type%28project%29

    https://sandbox.jiveon.com/api/core/v3/places?sort=dateCreatedAsc&filter=type%28space%29

    https://sandbox.jiveon.com/api/core/v3/places?sort=dateCreatedAsc&filter=type%28group%29

    Reference: Jive REST API v3.0 → Place service

     

    People

     

    Get active users

     

    Getting the active people is very easy: https://sandbox.jiveon.com/api/core/v3/people

    There seems to be a bug in 6.0.?, sometimes the "next" link is missing: Issue with API v3, when getting people?

    Therefore I loop over the users (startIndex=0,25,50,...) until I get an empty user list.

    Get disabled users

     

    The feature actually exists, but is not (yet?) listed in the docs:

    https://sandbox.jiveon.com/api/core/v3/people?filter=include-disabled(true)&fields=jive

     

    Update profile picture

    curl -i -u user:pass -X POST -F "file=@your_file.jpg;type=image/jpg" "https://your_jive_instance/api/core/v3/profileImages/temporary"

     

    Note:  When uploading images for other assets (non-profile) you can use the following end-point instead: POST https://your_jive_instance/api/core/v3/images

    Per this document: Jive REST Rest API v3.7 → Image service check for 201 status code and look at the Location header for the URL of the new Jive image that you can pass to:

    curl -i -u user:pass -X POST -F "imageURI=https%3A%2F%2Fyour_jive_instance%2Fapi%2Fcore%2Fv3%2FprofileImages%2Ftemporary%2FXXXXX" "https://your_jive_instance/api/core/v3/people/xxxx/images"

     

    Retrieving Information

     

    Suppress Metadata/Resources/Fields in API Response

     

    v3 API: Suppress Metadata/Resources in Response?

    • Example:  GET /api/core/v3/contents?fields=subject,content,-resources
      since Jive 7+ and Cloud