Cannot write to Scalix

Discuss the Scalix Messaging Services

Moderator: ScalixSupport

hduscalix
Posts: 11
Joined: Fri Jul 31, 2009 3:21 pm

Cannot write to Scalix

Postby hduscalix » Fri Jul 31, 2009 4:02 pm

Recently, we upgraded to Scalix 11.4.4. We have also been using the Scalix API to write to a scalix calendar. It was working before, does not seem to work now after the upgrade. Is the Scalix API compatible with the upgrade or is there a new API that we should be using? Thanks.

florian
Scalix
Scalix
Posts: 3852
Joined: Fri Dec 24, 2004 8:16 am
Location: Frankfurt, Germany
Contact:

Re: Cannot write to Scalix

Postby florian » Tue Aug 04, 2009 12:30 pm

some of the API calls have been streamlined and cleaned up in preparation for ActiveSync, however the API hasn't fundamentally changed. Doc has improved, too, see online at http://<yourservername>/api/docs

Also, if you're using mboxadmin access for doing this, note that a bug has been found in 11.4.4 where this is broken and a patch has been published, available on the support part of the website.

Florian
Florian von Kurnatowski, Die Harder!

hduscalix
Posts: 11
Joined: Fri Jul 31, 2009 3:21 pm

Re: Cannot write to Scalix

Postby hduscalix » Tue Aug 04, 2009 5:23 pm

This is the information we are using to get the connection:
URL: https://host/api/username@domain/mailbox/Calendar
Authorization: Basic (using Base64 encoding)
Content-Type: text/calendar
Other settings: setDoOutput = true, setDoInput = true, setUseCaches = false

We seem to be able to get the connection ok, but when we try to get the outputstream for writing, it fails. Basically, we need to write a calendar entry (and also read from the freebusy).

Thanks

florian
Scalix
Scalix
Posts: 3852
Joined: Fri Dec 24, 2004 8:16 am
Location: Frankfurt, Germany
Contact:

Re: Cannot write to Scalix

Postby florian » Wed Aug 05, 2009 3:29 am

I think the contents of the actual HTTP post that you're using (think: network trace of it!) would be more useful than just the basic connection information.

Also, is there an error message in scalix-api.log? You can increase log levels for this to DEBUG or TRACE and see if it gets more information on what's going on.

Florian
Florian von Kurnatowski, Die Harder!

hduscalix
Posts: 11
Joined: Fri Jul 31, 2009 3:21 pm

Re: Cannot write to Scalix

Postby hduscalix » Wed Aug 05, 2009 9:53 am

Where can I find info on the HTTP post and the scalix-api.log?

florian
Scalix
Scalix
Posts: 3852
Joined: Fri Dec 24, 2004 8:16 am
Location: Frankfurt, Germany
Contact:

Re: Cannot write to Scalix

Postby florian » Wed Aug 05, 2009 9:54 am

well, the POST is what YOU send to add the item and the log settings are in /var/opt/scalix/??/platform/log4j.properties.

Worst case, scalix-platform is Open Source, so you can look at and/or trace through our code.

Florian
Florian von Kurnatowski, Die Harder!

hduscalix
Posts: 11
Joined: Fri Jul 31, 2009 3:21 pm

Re: Cannot write to Scalix

Postby hduscalix » Wed Aug 05, 2009 4:05 pm

The only thing we could find in the logs was:
2009-08-05 15:43:41,373 WARN [PlatformDispatcherServlet.service:83] Problem processing request method=POST URI=/api/user@domain/mailbox/Calendar

Any ideas on what this means?

hduscalix
Posts: 11
Joined: Fri Jul 31, 2009 3:21 pm

Re: Cannot write to Scalix

Postby hduscalix » Wed Aug 05, 2009 4:18 pm

Should the URL for the connection be:
https://host/api/user@domain/mailbox/Calendar or
https://host/api/dav/Mailstore/user@domain/Calendar ?
(in our code we used Base64 for authentication with the https)

florian
Scalix
Scalix
Posts: 3852
Joined: Fri Dec 24, 2004 8:16 am
Location: Frankfurt, Germany
Contact:

Re: Cannot write to Scalix

Postby florian » Thu Aug 06, 2009 3:03 am

Both URLs are valid, however provide for different functionality and usecases.

One is a WebDAV URL where the mailstore is rendered as a WebDAV filesystem, the other is a RESTful web service providing for HTTP-based mailbox access; the latter is a proprietary API made by Scalix and documented in the api/docs URL mentioned earlier. WebDAV - and CalDAV, which is also found underneath the /api/dav root are open standards.

Florian.
Florian von Kurnatowski, Die Harder!

hduscalix
Posts: 11
Joined: Fri Jul 31, 2009 3:21 pm

Re: Cannot write to Scalix

Postby hduscalix » Thu Aug 06, 2009 11:19 am

Here is what we are doing in our code. Can you see anything wrong with it?

Code: Select all

   
String serverURL = "https://host/api/username@domain/mailbox/Calendar";
try {
   java.net.URLConnection conn;
   java.net.URL url;
   try {
      url = new URL(serverURL);
      conn = url.openConnection();

      // Try to open the connection...
      conn.addRequestProperty("Content-Type", "text/calendar");
      conn.addRequestProperty("Authorization", "Basic "
            + HttpUtils.basicAuth(userName, password));   // Uses Base64 encoding
      conn.setDoOutput(true);
      conn.setDoInput(true);
      conn.setUseCaches(false); // ensure up-to-date from server;
      conn.connect();
   } catch (IOException e) {
      ...
   }
   PrintWriter pw = new PrintWriter(new OutputStreamWriter(conn.getOutputStream()));    // HERE'S WHERE IT BREAKS: CAN'T SEEM TO GET
                                                   // AN OUTPUTSTREAM PROPERLY
   writeEvent(pw, a);
   pw.println();
   pw.close();
      ...
} catch (IOException e) {
   throw new RuntimeException("IO Error", e);
}


Here's the Error we got:

Code: Select all

{ Error | 2009-08-06 09:50:14.962 | } hdu Unable to store user's response (found below) to service request.:java.lang.RuntimeException: IO Error
{Stack Trace
java.lang.RuntimeException: IO Error
   at tcp.caleventservice.CalendarEventServiceScalixImpl.enterEvent(CalendarEventServiceScalixImpl.java:78)
   ...
Caused by: java.io.IOException: Server returned HTTP response code: 403 for URL: http://mail2.X.ca/api/dav/Mailstore/tgcore@X.ca/Calendar
   at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1290)
   at tcp.caleventservice.CalendarEventServiceScalixImpl.enterEvent(CalendarEventServiceScalixImpl.java:65)
   ... 45 more
}


And the warning in the Scalix log:

Code: Select all

2009-08-06 ... WARN [PlatformDispatcherServlet.service:83] Problem processing request method=POST URI=/api/user@domain/mailbox/Calendar

gren
Scalix
Scalix
Posts: 264
Joined: Thu Mar 25, 2004 10:27 am
Contact:

Re: Cannot write to Scalix

Postby gren » Fri Aug 07, 2009 4:20 am

Hi,

I notice the log says that the POST method failed. Your comment implies that you are trying to do a GET (hmm, but you are specifying a content type of text/calendar). The code doesn't seem to set the HTTP method - I wonder if it is defaulting to POST? Is there a way to specifically set the method? I mostly deal with the CalDAV side of the Scalix API - where GET and PUT are heavily used but POST is only used in slightly unusual circumstances. Perhaps if you say exactly what you are trying to achieve, we can compare that with which method the REST API requires.

Sorry, this is a quick and not particularly detailed analysis but hopefully gives you some possible things to think about.

Regards,
Gren.

hduscalix
Posts: 11
Joined: Fri Jul 31, 2009 3:21 pm

Re: Cannot write to Scalix

Postby hduscalix » Fri Aug 07, 2009 2:03 pm

Thanks for the help. I appreciate it. What do you mean by "comment implies that you are trying to do a GET": Is it the Base64 encoding? I didn't write the code for this, but it says that it's supposed to encode the username and password, and needs to use https. Does this do a GET automatically? I also couldn't find a way to set the method to POST explicitly using the URLConnection object, and just hoped that it defaulted to POST.

What we need to achieve through the code is to connect to a Scalix calendar account (a premium account) and write an event to the calendar. We were able to do this in the past with the same code, but does not work now. We suspect it may have to do with our recent Scalix upgrade to 11.4.4.

hduscalix
Posts: 11
Joined: Fri Jul 31, 2009 3:21 pm

Re: Cannot write to Scalix

Postby hduscalix » Fri Aug 07, 2009 3:35 pm

I found the way to set the method to POST using HttpURLConnection, but still get the error.

Code: Select all

url = new URL(URL);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
...
conn.setRequestMethod("POST");
System.out.println(conn.getRequestMethod()); // prints "POST"

I also noticed though that when I view the connection object in debug mode, the method variable is still showing "GET".

gren
Scalix
Scalix
Posts: 264
Joined: Thu Mar 25, 2004 10:27 am
Contact:

Re: Cannot write to Scalix

Postby gren » Mon Aug 10, 2009 11:12 am

Hi again,

I have now looked at the Scalix Messaging Services documentation at
http://<hostname>/api/docs#usingwebservices (where <hostname> is where you have it installed)

This shows that you are correct in using the POST method against the URL for the Calendar to add an item to the Calendar via the REST API.

Earlier, you said you had seen the following in the Scalix log :

Code: Select all

2009-08-06 ... WARN [PlatformDispatcherServlet.service:83] Problem processing request method=POST URI=/api/user@domain/mailbox/Calendar


From the source code, I would expect the Exception that caused this warning to be logged immediately following this. Could you paste that please.

Regards,
Gren.

hduscalix
Posts: 11
Joined: Fri Jul 31, 2009 3:21 pm

Re: Cannot write to Scalix

Postby hduscalix » Wed Aug 12, 2009 3:26 pm

Unfortunately, I do not have access to the logs right now. I can say though that with the code below, it goes through without exceptions in my console (though there may be exceptions in the scalix logs -- i do not know for sure), but there is still no event written to the calendar. I'll post the log message if I am able to get it soon.

Code: Select all

      String serverURL = "https://mail2.X.ca/api/tgcore@mail2.X.ca/mailbox/Calendar";
      try {
         java.net.HttpURLConnection conn;
         java.net.URL url;
         url = new URL(serverURL);
         conn = (HttpURLConnection) url.openConnection();

         // Try to open the connection...
         conn.addRequestProperty("Content-Type", "text/calendar");
         conn.addRequestProperty("Authorization", "Basic "
               + HttpUtils.basicAuth(userName, password));   // Uses Base64 encoding
         conn.setDoOutput(true);
         conn.setDoInput(true);
         conn.setUseCaches(false); // ensure up-to-date from server;
         conn.setRequestMethod("POST");
         conn.connect();
         PrintWriter pw = new PrintWriter(new OutputStreamWriter(conn.getOutputStream()));   
         writeEvent(pw, a);
         pw.println();
         pw.close();

      } catch (IOException e) {
         throw new RuntimeException("IO Error", e);
      }

Is it possible that this problem is related to one of the Known Issues for Scalix Messaging Services here http://downloads.scalix.com/rn/scalix-11.4.4-GA-releasenotes.html#known


Return to “Scalix Messaging Services”



Who is online

Users browsing this forum: No registered users and 7 guests