Yuri, That may be a problem. Can you try to upload just a regular Excel file in your code and see if that works?
Thanks - Jochen On Oct 14, 2:05 pm, theyurinator <[EMAIL PROTECTED]> wrote: > Thanks again for your response, > > The reason I specified the mime type is because > > 1) The setFile method that only takes the File object is now > deprecated > > 2) I saw your post here about specifying the mime > typehttp://groups.google.com/group/Google-Docs-Data-APIs/browse_thread/th... > > In any case, I tried using the deprecated version of setFile, but got > the same Service Exception with unsupported media type. > > One more thing I haven't mensioned yet is that since there doesn't > seem to be a way to create a new Google spreadsheet on the fly and add > information, I am making an Excel file using JXL and then trying to > upload that. I'm seeing the generated Excel file though, and it seems > to be fine. Could this be causing a problem? > > Thanks. > > Yuri > > On Oct 13, 6:46 pm, "Jochen Hartmann (Google)" > > <[EMAIL PROTECTED]> wrote: > > Hi, > > > If you look at the docs you will notice that you don't need to specify > > the MIME type at all. The API will infer it from the File object that > > you send. So I would recommend changing your code to match what we > > have in our documentation: > > >http://code.google.com/apis/documents/developers_guide_java.html#Uplo... > > > Cheers, > > - Jochen > > > On Oct 10, 4:02 pm, theyurinator <[EMAIL PROTECTED]> wrote: > > > > Hello, > > > > Thanks for the response. I did copy exactly what the documentation > > > had, except I have a couple additional things. These are: > > > > 1. Authenticating > > > > try { DocsService docs_service.setUserCredentials(user, pw); } > > > catch (AuthenticationException e) { e.printStackTrace(); } > > > > This shouldn't affect anything. In the documentation, there is already > > > a "service" that must have been initialized somewhere else and I'm > > > just doing it inside the method rather than outside. > > > > 2. Getting the feed URL > > > I make a FeedURLFactory and pass in factory.getItemsFeedURL because > > > again, the "documentListFeedUrl" in the documentation's example must > > > have been initialized outside of the method. > > > > com.google.api.gbase.client.FeedURLFactory factory = > > > com.google.api.gbase.client.FeedURLFactory.getDefault(); > > > try { DocumentListEntry upload = > > > docs_service_.insert(factory.getItemsFeedURL(), doc); } > > > catch (IOException e) { e.printStackTrace(); } > > > catch (ServiceException e) { e.printStackTrace(); } > > > > So, these are the only things I did differently from the > > > documentation's example. If I did anything wrong, I suspect it might > > > be the feed URL. getItemsFeedURL() sounded like the one I needed to > > > get, but I wasn't exactly sure. > > > > Thank you. > > > > Yuri > > > > On Oct 10, 3:05 pm, "Jochen Hartmann (Google)" > > > > <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > > I am not sure why you are writing your code like that. Can you just > > > > try running exactly what we have in our documentation: > > > > >http://code.google.com/apis/documents/developers_guide_java.html#Uplo... > > > > > Thanks > > > > - Jochen > > > > > On Oct 9, 4:00 pm, theyurinator <[EMAIL PROTECTED]> wrote: > > > > > > I forgot to mension--although it is probably evident from the code I > > > > > pasted--that I am using the Java API. > > > > > > I've tried passing in a variety of mime type strings, but I get the > > > > > same exception every time. Has anybody had similar issues? > > > > > > On Oct 8, 12:41 pm, theyurinator <[EMAIL PROTECTED]> wrote: > > > > > > > Hello, > > > > > > > I am trying to upload a spreadsheet and I am getting some > > > > > > exceptions I > > > > > > don't understand. > > > > > > > Here is my code: > > > > > > > private static void uploadSpreadsheet(String user, String > > > > > > pw, File f, > > > > > > String title) { > > > > > > try { DocsService > > > > > > docs_service_.setUserCredentials(user, pw); } > > > > > > catch (AuthenticationException e) { > > > > > > e.printStackTrace(); } > > > > > > > DocumentEntry doc = new DocumentEntry(); > > > > > > doc.setFile(f, "application/vnd.ms-excel"); > > > > > > doc.setTitle(new PlainTextConstruct(title)); > > > > > > > com.google.api.gbase.client.FeedURLFactory factory = > > > > > > com.google.api.gbase.client.FeedURLFactory.getDefault(); > > > > > > try { DocumentListEntry upload = > > > > > > docs_service_.insert(factory.getItemsFeedURL(), doc); } > > > > > > catch (IOException e) { e.printStackTrace(); } > > > > > > catch (ServiceException e) { e.printStackTrace(); } > > > > > > } > > > > > > > And here is the exception: > > > > > > > com.google.gdata.util.ServiceException: Unsupported Media Type > > > > > > Content-Type multipart/related;boundary="---- > > > > > > =_Part_0_20296179.1223494393761" is not valid. > > > > > > > at > > > > > > com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java: > > > > > > 525) > > > > > > at > > > > > > com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java: > > > > > > 558) > > > > > > at > > > > > > com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java: > > > > > > 479) > > > > > > at > > > > > > com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java: > > > > > > 458) > > > > > > at > > > > > > com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java: > > > > > > 530) > > > > > > at > > > > > > com.google.gdata.client.media.MediaService.insert(MediaService.java: > > > > > > 295) > > > > > > at > > > > > > com.swaytable.model.server.GoogleSpreadsheetProcessor.uploadSpreadsheet(GoogleSpreadsheetProcessor.java: > > > > > > 105) > > > > > > at > > > > > > com.swaytable.model.server.GoogleSpreadsheetProcessor.write(GoogleSpreadsheetProcessor.java: > > > > > > 303) > > > > > > at > > > > > > com.swaytable.model.server.GoogleSpreadsheetProcessor.main(GoogleSpreadsheetProcessor.java: > > > > > > 319) > > > > > > > I'm correctly setting the mime type to match Excel. What else am I > > > > > > missing? The only thing I am unsure of is whether I am getting the > > > > > > correct feed URL, but the errors don't seem to contain anything > > > > > > related to feed URLs, so I am a little confused. > > > > > > > Thanks, > > > > > > > Yuri --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Docs Data APIs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Docs-Data-APIs?hl=en -~----------~----~----~----~------~----~------~--~---
