On Wed, Feb 4, 2009 at 2:04 AM, JavaDecaf <[email protected]> wrote:
>
> Hi, I was trying to perform a very simple delete calendar event. But
> it gave me a Forbidden message. Below is the snipped code that I was
> using:
>
> CalendarService cs = new CalendarService(AppsConst.APPS_NAME);
> URL deleteUrl = new URL(event.getGEvent().getEditLink().getHref());
> cs.delete(deleteUrl);
>
> Exception thrown:
>
> Caused by: com.google.gdata.util.ServiceForbiddenException: Forbidden
> If-Match or If-None-Match header required
>
>        at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse
> (HttpGDataRequest.java:505)
>        at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse
> (GoogleGDataRequest.java:555)
>        at com.google.gdata.client.http.HttpGDataRequest.checkResponse
> (HttpGDataRequest.java:480)
>        at com.google.gdata.client.http.HttpGDataRequest.execute
> (HttpGDataRequest.java:459)
>        at com.google.gdata.client.http.GoogleGDataRequest.execute
> (GoogleGDataRequest.java:527)
>        at com.google.gdata.client.Service.delete(Service.java:1501)
>        at com.google.gdata.client.GoogleService.delete(GoogleService.java:
> 652)
>        at com.google.gdata.client.Service.delete(Service.java:1463)
>        at com.google.gdata.client.GoogleService.delete(GoogleService.java:
> 660)
>        at com.google.gdata.client.Service.delete(Service.java:1463)
>        at com.google.gdata.client.GoogleService.delete(GoogleService.java:
> 637)
>
> The closest clue that I can get is from:
> http://code.google.com/p/gdata-java-client/issues/detail?id=92. It
> looks very similar to my problem. I wonder if it was fixed.
>
> Please help =(

JavaDecaf,
Can you make sure that you're using the latest version of the Java
client library?

The following code worked for me:

        // Create service instance
        CalendarService service = new CalendarService("net.tjohns.scratchpad");
        service.setUserCredentials("[email protected]", "secretPassword");
        
        // Prepare event
        URL postUrl = new
URL("http://www.google.com/calendar/feeds/default/private/full";);
        CalendarEventEntry myEntry = new CalendarEventEntry();
        
        myEntry.setTitle(new PlainTextConstruct("This Shoudln't Exist!"));
        myEntry.setContent(new PlainTextConstruct("This event should be 
deleted. :)"));
        
        DateTime startTime = 
DateTime.parseDateTime("2009-02-11T15:00:00-08:00");
        DateTime endTime = DateTime.parseDateTime("2009-02-11T17:00:00-08:00");
        When eventTimes = new When();
        eventTimes.setStartTime(startTime);
        eventTimes.setEndTime(endTime);
        myEntry.addTime(eventTimes);
        
        // Send the request and receive the response:
        CalendarEventEntry insertedEntry = service.insert(postUrl, myEntry);
        
        // Delete the event!
        service.delete(new URL(insertedEntry.getEditLink().getHref()));

-- 
Trevor Johns

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Calendar Data API" 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-calendar-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to