0
votes

I am trying to upload an xml doc using the google docs api. But I get the exception of Illegal Argument Exception

The code to upload the doc is

        File file = new File("/Users/Sana/Downloads/Sana_Upload_test.xml");
        DocumentEntry newDocument = new DocumentEntry();
        newDocument.setFile(file, "xml");
        newDocument.setTitle(new PlainTextConstruct("Sana.xml"));
        client.insert(new URL("https://docs.google.com/feeds/default/private/full/"), newDocument);

The exception that I get is

Exception in thread "main" java.lang.IllegalArgumentException: Invalid media type:xml
    at com.google.gdata.util.ContentType.<init>(ContentType.java:323)
    at com.google.gdata.data.docs.DocumentListEntry.setFile(DocumentListEntry.java:298)
    at Documents.main(Documents.java:74)

I know that upload of any type of document is only available for premier accounts, but my question is to find out if there is any work around for this issue?

Thanks, Sana.

2

2 Answers

1
votes

I have a better way to upload any doc in here http://code.google.com/a/eclipselabs.org/p/googledocs-rse/ which is quick. If anyone has something else, please post it here.

0
votes

At the following codes, mime type string is wrong.

newDocument.setFile(file, "xml");

Please change as follows and try.

newDocument.setFile(file, "text/plain");

But Google Documents List API document does not say that you can uploaded "xml" file.