hi alllllllllllllllll

any help plz

hi all

i am currently working on an application that need to add, edit , insert and
update events( google calendar) ,i got as far as authenticating and getting
the existing events  , know i am trying to add an event :

according to google appi i should use http post method , along with the
authentication token , and media type (application/atom+xml) as headers +
event entry as a content.
/*adding my content and headers*/
entry as a content.
/* my content*/
new Thread() {

   @Override
 public void run() {
           Request req = new Request();
/*an entry sample on google api websit , to represent the body of the
message*/
                        final StringBuilder builder = new StringBuilder();
                                                 builder.append("<entry
xmlns='http://www.w3.org/2005/Atom' xmlns:gd='
http://schemas.google.com/g/2005'>");
                                                 builder.append("<category
scheme='http://schemas.google.com/g/2005#kind' term='
http://schemas.google.com/g/2005#event'></category>");
                                                 builder.append("<title
type='text'>Tennis with Beth</title>");
                                                 builder.append(" <content
type='text'>Meet for a quick lesson.</content><gd:transparency value='
http://schemas.google.com/g/2005#event.opaque'> </gd:transparency>");
                                                 builder.append("
<gd:eventStatus value='http://schemas.google.com/g/2005#event.confirmed'>
</gd:eventStatus>");
                                                 builder.append(" <gd:where
valueString='Rolling Lawn Courts'></gd:where>");
                                                 builder.append(" <gd:when
startTime='2010-03-17T15:00:00.000Z'
endTime='2010-04-17T17:00:00.000Z'></gd:when></entry>");

                                    // do the HTTP dance in a separate
thread (the responseHandler will fire when complete)

                                                String b =
builder.toString();

HashMap<String ,String> headers = new HashMap<String,String>();
/*my authentication token header*/
                       headers.put(Constant.GTOKEN_AUTH_HEADER_NAME ,
Constant.GTOKEN_AUTH_HEADER_VALUE_PREFIX+mTokenValue);

                        try {

/* my post request containing the url, + media type + body and headers*/
       Response re = req.postRequest ("
http://www.google.com/calendar/feeds/default/private/full";,
"application/atom+xml", b , headers);
                                                            AddResponse =
re.status + "\n\n"+ re.data;
                        } catch (ClientProtocolException e) {
                                                            // TODO
Auto-generated catch block

 e.printStackTrace();
                                                } catch (IOException e) {
                                                            // TODO
Auto-generated catch block

 e.printStackTrace();
                                                }



/*post request method*/
public Response postRequest (String url, String contentType, String body,
Map <String, String> headers) throws
ClientProtocolException,
IOException
{
if (url == null) {
throw new IllegalArgumentException ("url");
}
 if (contentType == null) {
throw new IllegalArgumentException ("contentType");
}
 if (body == null) {
throw new IllegalArgumentException ("body");
}
 HttpPost post = new HttpPost (url);
post.setHeader (HTTP.CONTENT_TYPE, contentType);

    if (headers != null) {
    for (Entry <String, String> e : headers.entrySet()) {
     post.addHeader (e.getKey (), e.getValue ());
    }
    }

    post.setEntity (new StringEntity (body));

return postRequest (post);
}
having sent the post method i got status code 200 ok instead of 201 created
for some reason along with following feed


+++++++++++++++++++++++++FDS++++++++++++++++++++++++++++++++
03-02 22:10:45.937: DEBUG/ReminderAppVersion_1.1(3636): <?xml version='1.0'
encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom'
xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:gCal='
http://schemas.google.com/gCal/2005' xmlns:gd='
http://schemas.google.com/g/2005'><id>
http://www.google.com/calendar/feeds/default/private/full</id><updated>2010-03-02T21:04:22.000Z</updated><category
scheme='http://schemas.google.com/g/2005#kind' term='
http://schemas.google.com/g/2005#event'/><title type='text'>
faithfullgh...@gmail.com</title><subtitle type='text'>
faithfullgh...@gmail.com</subtitle><link rel='alternate' type='text/html'
href='http://www.google.com/calendar/embed?src=faithfullgh...@gmail.com'/><link
rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml'
href='http://www.google.com/calendar/feeds/default/private/full'/><link
rel='http://schemas.google.com/g/2005#post' type='application/atom+xml'
href='http://www.google.com/calendar/feeds/default/private/full'/><link
rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml'
href='http://www.google.com/calendar/feeds/default/private/full/batch'/><link
rel='self' type='application/atom+xml' href='
http://www.google.com/calendar/feeds/default/private/full?max-results=25'/><author><name>alfadel
mohamed</name><email>faithfullgh...@gmail.com</email></author><generator
version='1.0' uri='http://www.google.com/calendar'>Google
Calendar</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><gCal:timezone
value='Europe/Dublin'/><gCal:timesCleaned value='2'/><entry><id>
http://www.google.com/calendar/feeds/default/private/full/qarpmjs6qdgjpplhbls3o4kv7k</id><published>2010-02-28T22:23:05.000Z</published><updated>2010-02-28T22:23:05.000Z</updated><category
scheme='http://schemas.google.com/g/2005#kind' term='
http://schemas.google.com/g/2005#event'/><title type='text'>my
event</title><content type='text'/><link rel='alternate' type='text/html'
href='
http://www.google.com/calendar/event?eid=cWFycG1qczZxZGdqcHBsaGJsczNvNGt2N2sgZmFpdGhmdWxsZ2hvc3RAbQ'
title='alternate'/><link rel='self' type='application/atom+xml' href='
http://www.google.com/calendar/feeds/default/private/full/qarpmjs6qdgjpplhbls3o4kv7k'/><link
rel='edit' type='application/atom+xml' href='
http://www.google.com/calendar/feeds/default/private/full/qarpmjs6qdgjpplhbls3o4kv7k/63403078985'/><author><name>alfadel
mohamed</name><email>faithfullgh...@gmail.com</email></author><gd:comments><gd:feedLink
href='
http://www.google.com/calendar/feeds/default/private/full/qarpmjs6qdgjpplhbls3o4kv7k/comments'/></gd:comments><gd:eventStatus
value='http://schemas.google.com/g/2005#event.confirmed'/><gd:where
valueString=''/><gd:who email='faithfullgh...@gmail.com' rel='
http://schemas.google.com/g/2005#event.organizer' valueString='alfadel
mohamed'/><gd:when endTime='2010-03-01T16:30:00.000Z'
startTime='2010-03-01T15:30:00.000Z'/><gd:transparency value='
http://schemas.google.com/g/2005#event.opaque'/><gd:visibility value='
http://schemas.google.com/g/2005#event.default'/><gCal:anyoneCanAddSelf
value='false'/><gCal:guestsCanInviteOthers
value='true'/><gCal:guestsCanModify value='false'/><gCal:guestsCanSeeGuests
value='true'/><gCal:sequence value='0'/><gCal:uid value='
qarpmjs6qdgjpplhbls3o4k...@google.com'/></entry></feed>

so i am wondering what is wrong here , any help will be appreciated.

/==========================google Api+++++++++++++++++++++++++++++++++++
Creating single-occurrence events
<entry xmlns='http://www.w3.org/2005/Atom'
    xmlns:gd='http://schemas.google.com/g/2005'>
  <category scheme='http://schemas.google.com/g/2005#kind'
    term='http://schemas.google.com/g/2005#event'></category>
  <title type='text'>Tennis with Beth</title>
  <content type='text'>Meet for a quick lesson.</content>
  <gd:transparency
    value='http://schemas.google.com/g/2005#event.opaque'>
  </gd:transparency>
  <gd:eventStatus
    value='http://schemas.google.com/g/2005#event.confirmed'>
  </gd:eventStatus>
  <gd:where valueString='Rolling Lawn Courts'></gd:where>
  <gd:when startTime='2006-04-17T15:00:00.000Z'
    endTime='2006-04-17T17:00:00.000Z'></gd:when>
</entry>
Note that this entry does not contain the standard APP <author> tag. The
server will insert author information based on the user that submits the
request (i.e. the user whose authentication token accompanies the request).
To post an entry, send the following HTTP request to Calendar, using a
special "default" URL (and an Authorization header; see the section on
authentication above). Calendar automatically redirects the default URL to
the URL of the read/write private feed of the calendar belonging to the
authenticated user. (Note that you don't have to use the default URL to send
a POST request to Calendar; you can specify the user ID instead of "default"
if you prefer. For more information, see the Calendar feed types reference.)
POST http://www.google.com/calendar/feeds/default/private/full
The content that you send with the POST request should be the <entry>
element you created above, using the application/atom+xml content type.
When you send that second POST request (or the first one in cases where
there's no redirect), Calendar creates a calendar event, then returns an
HTTP 201 CREATED status code, along with a copy of the new event in the form
of an <entry> element. The returned entry is similar to the one you sent,
but the returned one contains various elements added by Calendar, such as an
<id> element

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to