REST API Examples
This page contains some simple examples for Jive’s REST API to help you get started.
These examples use cURL but you can use any method you choose to send HTTP requests. All examples are run against the Jive Developer Sandbox (https://sandbox.jiveon.com), which is a free Jive instance that can be used for testing. If the HTTP request to a Jive REST API endpoint is successful, you receive a 2xx response code along with a JSON response, if applicable.
Check out the REST API Reference for detailed information.
Creating New Content
To create content, perform a POST to the relevant Content Service endpoint (/contents) and supply the appropriate Content Entity.
Create a discussion:
curl -v -u USERNAME
-k --header "Content-Type: application/json"
-d '{ "type": "discussion",
"subject": "My first discussion",
"content":
{ "type": "text/html",
"text": "<body><p>This is my discussion.</p></body>"
}
}'
"https://sandbox.jiveon.com/api/core/v3/contents"
See the POST /contents endpoint and the Discussion Entity for more information.
Create a document:
curl -v -u USERNAME
-k --header "Content-Type: application/json"
-d '{ "type": "document",
"subject": "My first document",
"content":
{ "type": "text/html",
"text": "<body><p>This is my document.</p></body>"
}
}'
"https://sandbox.jiveon.com/api/core/v3/contents"
See the POST /contents endpoint and the Document Entity for more information.
Create a document in a particular place:
curl -v -u USERNAME
-k --header "Content-Type: application/json"
-d '{ "type": "document",
"subject": "My document in a place",
"visibility": "place",
"parent": "https://sandbox.jiveon.com/api/core/v3/places/PLACE_ID",
"content":
{ "type": "text/html",
"text": "<body><p>This is my document.</p></body>"
}
}'
"https://sandbox.jiveon.com/api/core/v3/contents"
Replace PLACE_ID with the ID for that particular place.
See the POST /contents endpoint and the Document Entity for more information.
Create a private document visible to particular users:
curl -v -u USERNAME
-k --header "Content-Type: application/json"
-d '{ "type": "document",
"subject": "My private document",
"visibility": "people",
"users": [ "https://sandbox.jiveon.com/api/core/v3/people/USER_ID" ],
"content":
{ "type": "text/html",
"text": "<body><p>This is my document.</p></body>"
}
}'
"https://sandbox.jiveon.com/api/core/v3/contents"
Replace USER_ID with the ID for the user who should have access to this document. Use a comma-separated list to include additional users.
See the POST /contents endpoint and the Document Entity for more information.
Finding Content, People, Places
This section contains examples for finding people, places, and content.
- To find content, perform a GET on the Content Service endpoint (/contents) to get a paginated list of results.
- To find people, perform a GET on the Person Service endpoint (/people) to get a paginated list of results.
- To find places, perform a GET on the Place Service endpoint (/places) to get a paginated list of results.
You can filter the results using the filter query parameter. For example, when searching for places, filter=type(group) will only return groups rather than all place types.
You can limit the fields you get back using the fields query parameter. For example, when searching for users, fields=displayName will only return the display name for those users rather than all fields.
Refer to the REST API Reference for more tips on how to filter and parse the JSON response.
Browse all content:
curl -v -u USERNAME
"https://sandbox.jiveon.com/api/core/v3/contents"
See GET /contents for more information about this endpoint.
Browse all content authored by a particular user:
curl -v -u USERNAME
"https://sandbox.jiveon.com/api/core/v3/contents
?filter=author(https://sandbox.jiveon.com/api/core/v3/people/USER_ID)"
Replace USER_ID with the ID of the author. Use “@me” for the currently logged in user.
See GET /contents for more information about this endpoint.
Browse all content, returning just the subject field:
curl -v -u USERNAME
"https://sandbox.jiveon.com/api/core/v3/contents?fields=subject"
See GET /contents for more information about this endpoint.
Browse for the third page of 100 content items:
curl -v -u USERNAME
"https://sandbox.jiveon.com/api/core/v3/contents?count=100&startIndex=200"
See GET /contents for more information about this endpoint. Refer to Paginated Lists for more information about browsing through lists.
Query for information about a specific piece of content:
curl -v -u USERNAME
"https://sandbox.jiveon.com/api/core/v3/contents/CONTENT_ID"
See GET /contents/{contentID} for more information about this endpoint.
Get all replies to a discussion:
curl -v -u USERNAME
"https://sandbox.jiveon.com/api/core/v3/messages/contents/CONTENT_ID"
See GET /messages/contents/{contentID} for more information about this endpoint.
Browse for a place based on a search string:
curl -v -u USERNAME
"https://sandbox.jiveon.com/api/core/v3/places?filter=search(test*group)"
See GET /places for more information about this endpoint.
Browse for a person based on an email address:
curl -v -u USERNAME
"https://sandbox.jiveon.com/api/core/v3/people/email/johndoe@example.com"
See GET /people/email/{email} for more information about this endpoint.
Query for information about me:
curl -v -u USERNAME
"https://sandbox.jiveon.com/api/core/v3/people/@me"
See GET /people/{personID} for more information about this endpoint.
TIP: You can use @me throughout the Jive REST API to denote the authenticated user.
Acting on / Updating Content
This section covers various ways to interact with existing content.
Update a document:
curl -v -u USERNAME -X PUT
-k --header "Content-Type: application/json"
-d '{ "subject": "My UPDATED document subject",
"author": { "id" : "USER_ID", "type": "person" },
"type": "document",
"parent" : "https://sandbox.jiveon.com/api/core/v3/places/PLACE_ID",
"status" : "published",
"tags" : [ ],
"content":
{ "type": "text/html",
"text": "<body><p>My UPDATED content.</p></body>"
}
}'
"https://sandbox.jiveon.com/api/core/v3/contents/CONTENT_ID"
You can find the values for USER_ID and PLACE_ID by performing a GET request on the applicable Content Service endpoint (/contents).
See PUT /contents/{contentID} for more information about this endpoint.
Reply to a discussion:
curl -v -u USERNAME
-k --header "Content-Type: application/json"
-d '{ "type": "message",
"content":
{ "type": "text/html",
"text": "<body><p>This is a discussion reply.</p></body>"
}
}'
"https://sandbox.jiveon.com/api/core/v3/messages/contents/CONTENT_ID"
Replace CONTENT_ID with the ID for the discussion you are replying to.
See POST /messages/contents/{contentID} for more information about this endpoint.
Comment on a document:
curl -v -u USERNAME
-k --header "Content-Type: application/json"
-d '{ "type": "comment",
"content":
{ "type": "text/html",
"text": "<body><p>Your document is brilliant.</p></body>"
}
}'
"https://sandbox.jiveon.com/api/core/v3/contents/CONTENT_ID/comments"
Replace CONTENT_ID with the ID for the document you are commenting on.
See POST /contents/{contentID}/comments for more information about this endpoint.
Like a piece of content:
curl -v -u USERNAME -X POST
"https://sandbox.jiveon.com/api/core/v3/contents/CONTENT_ID/likes"
See POST /contents/{contentID}/likes for more information about this endpoint.
Miscellaneous Examples
This section contains various other REST API examples.
Update a person's status:
curl -v -u USERNAME -X PUT
-k --header "Content-Type: application/json"
-d '{ "status": "I am pretty excited about REST APIs!",
"emails" : [ {
"jive_label" : "Email",
"value" : "USER_EMAIL"
} ],
"jive" : {
"username" : "USERNAME"
},
"name" : {
"familyName" : "USER_FAMILYNAME",
"givenName" : "USER_GIVENNAME"
},
"type" : "person"
}'
"https://sandbox.jiveon.com/api/core/v3/people/@me"
USER fields can be acquired by querying for the user with a GET request to the Person Service (/people).
See PUT /people/{personID} for more information about this endpoint.
View all my activity streams:
curl -v -u USERNAME
"https://sandbox.jiveon.com/api/core/v3/people/@me/streams"
See GET /people/{personID}/streams for more information about this endpoint.
Next Steps
Check out the REST API Reference and the resources in the Jive Developer Community for more about the REST API.
Visit Developer Introduction for an overview of the entire Jive Development Platform.