皆様はじめまして、しゃおと申します。
http://code.google.com/intl/ja/apis/gdata/
にて公開されている、Google Documents List APIを用いてスプレッドシートの新規作成を試みているのですが、
DocsServiceインスタンスからinsertメソッドを実行した際に
com.google.gdata.util.ServiceExceptionが発生してうまくいきません。
渡しているURLに問題があるのではないかと疑っているのですが、新規で作成する場合の指定方法をご存じのかたはいらっしゃらないでしょうか?
以下、記述したソースの該当箇所です。
(画面からの入力内容を記述したスプレッドシートを新規作成し、シートへ記載するプログラムにする予定です)
<ソース>
public class HogeServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException, ServletException {
// 新規ドキュメントの生成
//--------------------------------------------------------------------------------------------------//
// サービス権限の取得
// DocsServiceを取得する
DocsService client = null;
try {
client = SpreadsheetUtil.getDocstService();
} catch (AuthenticationException e3) {
// TODO 自動生成された catch ブロック
e3.printStackTrace();
}
// 新規ドキュメントの生成
//--------------------------------------------------------------------------------------------------//
SpreadsheetEntry newEntry = null;
newEntry = new SpreadsheetEntry();
newEntry.setTitle(new PlainTextConstruct("NewTitleSheet"));
try {
client.insert(new URL("
https://docs.google.com/"), newEntry);
} catch (ServiceException e1) {
// TODO 自動生成された catch ブロック
e1.printStackTrace();
}
// シートへの記載
//--------------------------------------------------------------------------------------------------//
//(省略)//
}
}
public class SpreadsheetUtil {
public static DocsService getDocstService()
throws AuthenticationException {
// このアプリケーションの名称。任意の名前を設定する。
String applicationName = "hoge-sample-1";
// GoogleAppsもしくはGoogleアカウントのメールアドレスとパスワードを設定する。
String username = "hoge";
String password = "hoge";
// Docsサービスへの認証を行う。
DocsService service = new DocsService(applicationName);
service.setUserCredentials(username, password);
return service;
}
}
<エラー>
com.google.gdata.util.ServiceException: Invalid redirected-to URL - /
DocAction?action=unsupported_browser&gsessionid=[セッションIDが返ってきています]
at
com.google.gdata.client.GoogleService.handleRedirectException(GoogleService.java:
711)
at com.google.gdata.client.GoogleService.insert(GoogleService.java:
601)
at
com.google.gdata.client.media.MediaService.insert(MediaService.java:
381)
at easyalarm.EditAlarmInfoServlet.doGet(EditAlarmInfoServlet.java:
122)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:
511)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1166)
at
com.google.appengine.api.blobstore.dev.ServeBlobFilter.doFilter(ServeBlobFilter.java:
58)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.apphosting.utils.servlet.TransactionCleanupFilter.doFilter(TransactionCleanupFilter.java:
43)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
com.google.appengine.tools.development.StaticFileFilter.doFilter(StaticFileFilter.java:
122)
at org.mortbay.jetty.servlet.ServletHandler
$CachedChain.doFilter(ServletHandler.java:1157)
at
org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:
388)
at
org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:
216)
at
org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:
182)
at
org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:
765)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:
418)
at
com.google.apphosting.utils.jetty.DevAppEngineWebAppContext.handle(DevAppEngineWebAppContext.java:
70)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at com.google.appengine.tools.development.JettyContainerService
$ApiProxyHandler.handle(JettyContainerService.java:349)
at
org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:
152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:
542)
at org.mortbay.jetty.HttpConnection
$RequestHandler.headerComplete(HttpConnection.java:923)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at
org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:
409)
at org.mortbay.thread.QueuedThreadPool
$PoolThread.run(QueuedThreadPool.java:582)