文章(Document)の新規追加を行いたいんです。。。
一覧と編集は既に解ったのですが新規登録の方法がどうしても解らない。。。
この Google Docs API はリクエスト先のURLが自分的には特殊で解りにくいです。。。
もっと解りやすいリファレンスがあったらな。。。
URLが間違っているのか?
POSTでリクエストじゃないのか?
AtomContentの使い方が違うのか。。。
誰か教えてください。。。
public class Category {
String scheme = "http://schemas.google.com/g/2005#kind";
String term = "http://schemas.google.com/docs/2007#document";
}
public class Entry {
public Category category = new Category();
public String title;
}
public void addNewDocument(String title)
{
showDialog(this, "Debug", "addNewDocument");
// GoogleTransportからPOSTリクエストを生成
HttpRequest request = mTransport.buildPostRequest();
// URLを生成して
String url = GoogleDocumentsList.ROOT_URL + "default/private/full";
// URLをセット
request.setUrl(url);
// Content
AtomContent content = new AtomContent();
Entry entry = new Entry();
entry.title = "newDocument";
content.entry = entry;
content.namespaceDictionary = GoogleDocumentsListAtom.NAMESPACE_DICTIONARY;
PlainTextContent content2 = new PlainTextContent("sample");
request.content = content2;
// HttpRequestのヘッダーのifMatchに"*"をセット
request.headers.ifMatch = "*";
try {
// HTTPリクエストを実行!
request.execute();
} catch (IOException e) {
e.printStackTrace();
}
}
0 件のコメント:
コメントを投稿