How to create an activity for another other user with IBM OpenSocial

115 views Asked by At

I'm trying to create a new activity programmatically (using a POST to the /activities/service/atom2/activities URL). This works fine if I'm authenticating with the desired user. Actually I do want to create activities on behalf of another user (e.g. connect with an "admin") and tried to fill the "author" and "contributor" elements of the feed entry XML body.

Depending on the information I send it will be either ignored or I do get a HTTP 400 with a com.ibm.openactivities.atom.exception.ParsingException: java.lang.NullpointerException body.

I send something like this:

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<title type="text">A test</title>
<author>
  <name>Foo Bar</name>
  <email>[email protected]</email>
  <snx:userid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">34E7B1AD-3BCC-4C0F-B0EA-C9657D265C39</snx:userid>
  <snx:ldapid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">34E7B1AD-3BCC-4C0F-B0EA-C9657D265C39</snx:ldapid>
</author>
<contributor>
  <name>Foo Bar</name>
  <email>[email protected]</email>
  <snx:userid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">34E7B1AD-3BCC-4C0F-B0EA-C9657D265C39</snx:userid>
  <snx:ldapid xmlns:snx="http://www.ibm.com/xmlns/prod/sn">34E7B1AD-3BCC-4C0F-B0EA-C9657D265C39</snx:ldapid>
</contributor>
<category scheme="http://www.ibm.com/xmlns/prod/sn/type" term="activity" label="Activity" />
<content type="html">This is the &lt;b&gt;bold&lt;/b&gt; test body</content>
</entry>

And this is the result:

<error xmlns="http://www.ibm.com/xmlns/prod/sn">
  <code></code>
  <message>Identifier: LC036D7B74CB004EF9882FA53FFDD1A195 com.ibm.openactivities.atom.exception.ParsingException: com.ibm.openactivities.atom.exception.ParsingException: java.lang.NullPointerException</message>
  <displaymessage></displaymessage>
  <errortype></errortype>

  <trace>java.lang.Exception: Identifier: LC036D7B74CB004EF9882FA53FFDD1A195
com.ibm.openactivities.atom.exception.ParsingException: com.ibm.openactivities.atom.exception.ParsingException: java.lang.NullPointerException</trace>
</error>

The main question is can I create a new activity for another user? The second question is whether I can achieve it using the approach mentioned above, and the third question is what do I have to pass?

1

There are 1 answers

0
leyrer On

The IBM Connections API documentation states:

Using the Atom Publishing Protocol, also known as AtomPub, you can create and update activities that you own

Also, the documentation states, that in an Activity content entry, the "Author" element is ignored on input.

So from what I gather, you can only create Activities and Activity Entries for the user you have credentials for. Maybe you can work with an Activity ToDo Entry you assign to someone or with an Activity inside a Community?