I tried your solution and it fails for newly created spreadsheets with
ResourceNotFoundException, so I tried waiting a few seconds after
creating a spreadsheet and then setting the content and it works.
Looks like it's the same bug as issue 1147.
So until it's fixed I'll use version 1.
Thanks.

About the Java documentation, I'd be happy to contribute as much as I
know. Can I join in?

Gabriel

On May 10, 5:15 am, "Eric (Google)" <api.e...@google.com> wrote:
> I just tried this and it worked:
>
> service.getRequestFactory().setHeader("If-Match", "*");
> entry.setMediaSource(new MediaByteArraySource("1,2,3".getBytes(),
> "text/csv"));
> entry.updateMedia(false);
>
> I suspect you have an outdated etag.  That's where the
> precondition failed is coming from.
>
> Eric
>
> On May 9, 6:54 pm, "Eric (Google)" <api.e...@google.com> wrote:
>
> > Hi Gabriel,
>
> > Sorry for the troubles.  You're absolutely right about the
> > Java developer's guide.  It needs a reahaul :)
>
> > This may be a bug that I'll need to look in to,
> > but have you tried setting the If-Match header to If-Match: *?
>
> > You could also use Gdata-Version: 1.0 if you don't
> > want to mess with etags.
>
> > Eric
>
> > On May 9, 11:56 am, Gabriel <guz...@gmail.com> wrote:
>
> > > Hi,
>
> > > I opened an invalid issue report about updating document content with
> > > the Java library (http://code.google.com/p/gdata-issues/issues/detail?
> > > id=1200) and I got an explanation about the version difference.
> > > However I still don't understand how to do it. I didn't change the
> > > protocol version, so I figure I'm using the default 2.0. When I tried
> > > to do something like the following:
>
> > > storedEntry.setMediaSource(new MediaByteArraySource(csvContent.getBytes
> > > (), "text/csv"));
> > > storedEntry.updateMedia(false);
>
> > > I get the following exception:
>
> > > java.lang.IllegalStateException:
> > > com.google.gdata.util.ServiceForbiddenException: Forbidden
> > > If-Match or If-None-Match header required
>
> > > So i tried adding the following command before that:
>
> > > docsService.getRequestFactory().setHeader("If-Match",
> > > storedEntry.getEtag());
>
> > > and then I got this exception:
>
> > > com.google.gdata.util.PreconditionFailedException: Precondition Failed
> > > Resource does not support Etags
>
> > > So what is the correct way to do it? The documentation for the Java
> > > client doesn't cover this at all.
>
> > > Thanks,
>
> > > Gabriel
>
>
--~--~---------~--~----~------------~-------~--~----~
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 Google-Docs-Data-APIs@googlegroups.com
To unsubscribe from this group, send email to 
google-docs-data-apis+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Docs-Data-APIs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to