Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Create Event in Community - ActivityService.createActivity ? #1737

Closed
SiriSch opened this issue Nov 23, 2015 · 5 comments
Closed

Create Event in Community - ActivityService.createActivity ? #1737

SiriSch opened this issue Nov 23, 2015 · 5 comments
Labels

Comments

@SiriSch
Copy link

SiriSch commented Nov 23, 2015

Hey Paul,

I am trying to create an event in a community.

com.ibm.sbt.services.client.ClientServicesException: Request to url URLCENSORED/activities/service/atom2/activities returned an error response 400:Bad Request HTTP/1.1 400 Bad Request
 public static void test() throws ClientServicesException, ParseException {

    Activity anActivity = new Activity();
    anActivity.setTitle( "TEST" );
    anActivity.setCompleted( false );
    anActivity.setContent( "Interesting" );

    Date startDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.S" ).parse( "2015-11-16 17:00:00.0" );
    Date endDate = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss.S" ).parse( "2015-12-31 23:00:00.0" );

    anActivity.setDuedate( endDate );
    anActivity.setCommunityUuid( "72d67a94..." );
    Variables.anActivityService.createActivity( anActivity );
  }

but this of course does not work, because I can't find any property to set the start date.

Could you give me an example how to create an event in a community?

I am looking forward to hearing from you.

Best regards,

Sirius S.

@prb112
Copy link
Contributor

prb112 commented Nov 23, 2015

These are not equivalent APIs - IBM Connections Activities is not equivalent to IBM Connections Events. There is no coverage for Events. Please implement your own service based on the API - http://www-10.lotus.com/ldd/appdevwiki.nsf/xpAPIViewer.xsp?lookupName=API+Reference#action=openDocument&res_title=Community_Events_API_ic50&content=apicontent

@prb112 prb112 closed this as completed Nov 23, 2015
@prb112
Copy link
Contributor

prb112 commented Nov 23, 2015

refer to #1643

@SiriSch
Copy link
Author

SiriSch commented Dec 14, 2015

Hey and thanks,

I still have some problems with creating a community event.

I have got the following function now:

// Variables.baseURL is my URL
//calendarUuid is the calendarUuid I currently give as parameter (I have checked this before by using Google Chrome)
//Variables.anActivityService is an activity service (working properly), instantiatied like this:

    Variables.anActivityService = new ActivityService();
    Variables.anActivityService.setEndpoint( Variables.basicEndpoint );

public static boolean CreateCommunityEvent(String calendarUuid, String eventTitle, String eventContent)
throws ClientServicesException, ParseException {

String serviceURL = Variables.baseURL + "/communities/calendar/atom/calendar/service?calendarUuid=" + calendarUuid;
HttpResponse res = Variables.anActivityService.retrieveData( serviceURL, null ).getResponse();
HttpEntity entity = res.getEntity();
String contentt = "";

try {
  contentt = EntityUtils.toString( entity );
}
catch (org.apache.http.ParseException | IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
}
System.out.println( contentt );

serviceURL = Variables.baseURL + "/communities/calendar/atom/calendar/event?calendarUuid=" + calendarUuid;

String content =
  "<entry xmlns:snx=\"http://www.ibm.com/xmlns/prod/sn\" (http://www.ibm.com/xmlns/prod/sn%22)  xmlns:atom=\"http://www.w3.org/2005/Atom\" (http://www.w3.org/2005/Atom%22)  xmlns=\"http://www.w3.org/2005/Atom\"> (http://www.w3.org/2005/Atom%22%3E)"
    + "<title type=\"text\">$TITLE</title>" + "<content type=\"html\"><p dir=\"ltr\">$CONTENT</p> </content>"
    + "<snx:imageUrl></snx:imageUrl>" + "<snx:location></snx:location>" + "<snx:allday>0</snx:allday>"
    + "<category scheme=\"http://www.ibm.com/xmlns/prod/sn/type\" (http://www.ibm.com/xmlns/prod/sn/type%22)  term=\"event\"></category>"
    + "<snx:recurrence custom=\"yes\">" + "<snx:period>" + "<snx:startDate>2015-11-14T14:00:00-05:00</snx:startDate>"
    + "<snx:endDate>2015-12-14T15:00:00-05:00</snx:endDate>" + "</snx:period>"
    // + "<snx:daylight>2015-12-14T11:18:47-04:00/2015-12-14T10:18:47-05:00</snx:daylight>"
    + "</snx:recurrence>" + "</entry>";

content = content.replace( "$TITLE", eventTitle );
content = content.replace( "$CONTENT", eventContent );

return Variables.anActivityService.createData( serviceURL, null, content ).getResponse().getStatusLine()
  .getStatusCode() == 201;

}



Firstly, I get this error:

```java
java.io.IOException: Attempted read from closed stream.
    at org.apache.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:162)
    at org.apache.http.conn.EofSensorInputStream.read(EofSensorInputStream.java:137)
    at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)

On the other hand I get this error:

com.ibm.sbt.services.client.ClientServicesException: Request to url https://OURHOST/communities/calendar/atom/calendar/event?calendarUuid=82fd37fd-4c24-4eb4-9a12-9050aa8a580d returned an error response 403:Forbidden HTTP/1.1 403 Forbidden [Date: Mon, 14 Dec 2015 09:44:49 GMT, X-Frame-Options: SAMEORIGIN, Strict-Transport-Security: max-age=max-age=31536000;includeSubDomains, X-XSS-Protection: 1;mode=block, X-Permitted-Cross-Domain-Policies: master-only, X-Powered-By: Servlet/3.0, X-LConn-Auth: true, X-UA-Compatible: IE=9,8, Expires: Thu, 1 Jan 1970 00:00:00 GMT, Cache-Control: no-store, no-cache, must-revalidate, Set-Cookie: LtpaToken2=Utd55NmmMOUfNcbKM/DAs8WGj5XwfhZVwpX3P2kruDDsEl0Fst+65eMgbz+oQMSVWnvDypXZKCjz+7anCO0gP95PgJ4IKyAPCbW1GStsE3bO/293PI5WK+N+j4ciQErSkmhdwBSokOzta1a2sNuPWojIDAfzd7A2i40Fz4/dO7OKFzQwM6C1ihmbh61AT7BgZlOr8KYL/Ae1/jvNPO9s8SSMWg7R+5GmrT6p1uV6jvA6VFp3NtbQQr+TJKCDG7zOub8NZLjVWZJJSocaBr6F07f23miKWBa8wcFm37Hgighm7imiyTO51kku3vESDqo6XedngKIdYixyK3oX5Y1ZFNycjNyrU80f81OYojfI4H3vE3HrF2QCWkKi7J36HUX+1Am1l39SeavTfsTP5Laqr4FdTaTGg/7qC/7aBBuhU9CXo5v/VpA8Kw9B/wdm1Cp7MStzGc6qGXbWrmTIWVBmC+ZIvWYayIBBZwgbj9oNFAiGNDDimRh7HRcOapu6j2g9k4zzE1VXHtd3Tg8bwNKj9eFnQOWa2EbXzrXMn3CwmFfNzRl7L2HsblSV7X0dNV5G4nlPyGXl1+ICpN+c1S+aWBJ44q/LXKDjU/jJe2xv0jlNK3QfjsFz4XuM/Vhg+/PBKT7G9SXBBlFja319GJ+6pBr72G2gLtIFdw7E9LzoYm5S2pA/Kfwoyp+F69abBLAc; Path=/; Domain=.OURHOST.COM, Set-Cookie: LtpaToken=UBqbMhDmRzgZDSBIi+om7+9QxmMrseGs8LMCqdBfLf6rmf+/HGLXLea6N/T9h3KnFmju1MUHcnzKoqsbGZ84w8gZiP/Bqg6jYH8vEtfOIWTl7uIgo6SLDXRWRFWleoct9bbX/W5WKBtCEKqmapz7eTcmGKbqPiRcUv85+B7p0QIygLDtSsF2itj+Z0TDMSrqmly4afRDh47Z1/Vy2Murlcn9BD7g5uwNUq4/rzmb1xsDnynNLY9WMX9vKd+EGCISobVqsnlkYOBv0+kbTga4ByNgAsZ9zhFD4eWtqgP2n+qijHcykFEF/CCrtgxv9BwIPnF+Ar8a8GnTyB+6H2d0soOm2BPLxnGM; Path=/; Domain=.OURHOST.COM, Set-Cookie: connect=de_de; Path=/; Domain=.OURHOST.COM, Vary: Accept-Encoding,User-Agent, Content-Length: 0, Keep-Alive: timeout=10, max=100, Connection: Keep-Alive, Content-Language: de-DE]

What is wrong there?

I am looking forward to hearing from you.

Best regards,

Siri

@prb112
Copy link
Contributor

prb112 commented Dec 14, 2015

you have a ton of junk in your xml. example - xmlns:snx="http://www.ibm.com/xmlns/prod/sn\" (http://www.ibm.com/xmlns/prod/sn%22)

@SiriSch
Copy link
Author

SiriSch commented Jan 19, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants