POSTing new events
Added by IBM contributorIBM | Edited by Claudia R Elbourn on June 30, 2015
Rate this article 1 starsRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars1 comment

To POST an event to the Stream, you simply create an HTTP POST request with the new event details and POST to the stream in which you'd like the event to appear.

POSTing a simple event to the currently Authenticated user

1. Open your browser
2. Log in to IBM Connections (your login session will be used by your REST Client)
3. Open your REST Client (e.g. https://addons.mozilla.org/en-US/firefox/addon/restclient/)
4. Set the URL to http:///connections/opensocial/rest/activitystreams/@me/@all
5. Set the Method to POST
6. Paste the sample event below into the body section
7. Add the "Content-Type" header (e.g. "application/json; charset=UTF-8")
8. Add the "Accept" header (e.g. "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
9. Select SEND

Notes

  • You will generally use /connections/opensocial/basic/rest/activitystreams/@me/@all or /connections/opensocial/oauth/rest/activitystreams/@me/@all if POSTing from an API based application as these reflect Basic and OAuth based authentication respectively. The URL above works from the browser because your session is already available to it.
  • Depending on how you installed IBM Connections there may be an additional context root (i.e. http:////connections/opensocial/rest/activitystreams/@me/@all)

POSTing a simple batch request to the currently Authenticated user



It is possible to post multiple activity entries with a single HTTP POST request. The url endpoint is the same as for the single activity entry :/connections/opensocial/rest/activitystreams/@me/@all/@all, however please note that if posting to the @public/@all endpoint then all activity entries in the request will be posted to the @Public / Discover feed. If a higher level of granularity is required, then you can specify individual activity entries to appear in the discover feed, by specifying @public in either the deliverTo or cc property of the activity entry.

The body of the request must be a comma separated array or list of activity entries, i.e. [{Activity Entry 1}, {Activity Entry 2}, {Activity Entry 3}].

An example body is as follows:

 


[

{"actor":{"id":"@me"},"object":{"id":"a"},"generator":{"id":"An External Application"}}, 

{"actor":{"id":"@me"},"object":{"id":"b"},"generator":{"id":"An External Application"}},

{"actor":{"id":"@me"},"object":{"id":"c"},"generator":{"id":"An External Application"}}

]

 

POSTing an @mention event

An "@mention event" is an event that is returned under the @me/@mentions feed of the Activity Stream (the "@Mention" view in the Connections Homepage user interface).

The POST request are made against /@me/@all/@all as for other events.


The specific aspects:

1. The verb must be the string "mention".
2. The target of the event ("to" field) must be the mentioned users.
3. The summary fields accept the microformat @label of mention, where externalId is the fully prefixed external id of the user. On retrieval, the microformat is transformed to a link HTML markup.
Note that the HTML markup is parsed and recognized as a business card when the Activity Stream feed is rendered in the Connections UI.

See also the example at the bottom of this wiki page.

Associated template title strings:
mention={Actor} mentioned {Object}.
mention.in.target={Actor} mentioned {Object} in {Target}.
mention.you={Actor} mentioned you.
mention.you.in.target={Actor} mentioned you in {Target}.

Input
Method URI Description
POST /connections/opensocial/{auth}/rest/activitystreams/@me/@all POST an event to the Stream
Content Type: application/json
Sample Request:
 {

  "actor": {

    "id": "@me"

  },

  "verb": "post",

  "title": "${share}",

  "content":"This event is my <b>first entry</b>",

  "updated": "2012-01-01T12:00:00.000Z",

  "object": {

    "summary": "First Entry details",

    "objectType": "note",

    "id": "objectid",

    "displayName": "First entry",

    "url": "http://myurl.com/myid"

  }

}

Name Type Optional Description
auth
enumerated No The authorization protocol being used by your application to access Connections Cloud.
Authorized values:
  • basic
  • oauth
Name Type Optional Description
Authorization
enumerated No The authentication mechanism selected by your application to access the API.
Basic is the Base64 encoding of the IBM Connections Cloud username and password: Base64(username:password). For example, Base64(twatson@us.ibm.com:password).
Bearer is the oauth 2.0 access token that is generated when the user grants your application access to IBM Connections Cloud services.
See the reference topic "OAuth 2.0 APIs for web server flow" for more information.
Authorized values:
  • bearer
  • basic
Output
Content Type: application/json
Code Description
401
Unauthorized. Returned when no authenticated user or no userid, email, or key parameter are provided on the request.
Examples
Example of POST made to <activityStreamCtxRoot>/@me/@all/@all
{
  "generator": {
    "id":"An External Application1"
  },
  "actor": {
    "id":"@me"
  },
  "title":"${mention.you}",
  "to": [
        {
      "objectType":"person",
      "id":"urn:lsid:lconn.ibm.com:profiles.person:510b99c0-0101-102e-893f-f78755f7e0ed"
    }
  ],
  "object": {
    "summary":"hey @{{urn:lsid:lconn.ibm.com:profiles.person:510b99c0-0101-102e-893f-f78755f7e0ed|@Amy Jones102}}",
    "id":"c"
  },
  "verb":"mention"
}

Jonas Winzen commented on Oct 22, 2015

Re: POSTing new events

What is the meaning of /@me/@all/@all ?