accouding calendar api i should send the following xml
<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='2009-08-18T15:00:00.000Z'
endTime='2009-08-18T17:00:00.000Z'></gd:when>
</entry>
just modify the startTime and endTime , i copy from the google
examples
and do a post request with appliction/atom+xml content-type to
server
it return me a http 200 response code , not 201 create response
code .
i am not sure that the calendar api is suit for android platform , but
i have got get event and calendar list, it work well . only post that
xml to google server and do a delete request (delete a event ) that
has some problem
DefaultHttpClient client = new DefaultHttpClient();
// add user and pass to client credentials if present
if ((user != null) && (pass != null)) {
Log.d(LOGTAG, " " + HTTPRequestHelper.CLASSTAG
+ " user and pass present, adding credentials to
request");
client.getCredentialsProvider().setCredentials
(AuthScope.ANY, new UsernamePasswordCredentials(user, pass));
}
// process headers using request interceptor
final Map<String, String> sendHeaders = new HashMap<String,
String>();
if ((headers != null) && (headers.size() > 0)) {
sendHeaders.putAll(headers);
}
if (sendHeaders.size() > 0) {
client.addRequestInterceptor(new HttpRequestInterceptor()
{
public void process(final HttpRequest request, final
HttpContext context) throws HttpException,
IOException {
for (String key : sendHeaders.keySet()) {
if (!request.containsHeader(key)) {
Log.d(LOGTAG, " " +
HTTPRequestHelper.CLASSTAG + " adding header: " + key + " | "
+ sendHeaders.get(key));
request.addHeader(key, sendHeaders.get
(key));
}
}
request.setHeader("Content-Type", "application/
atom+xml");
request.addHeader("Content-Type", "application/
atom+xml");
for(Header h : request.getAllHeaders())
{
Log.d(LOGTAG, " appliction request
header22222." +h.getName()+" | "+h.getValue() );
}
}
});
}
HttpPost method = new HttpPost(url);
try {
// java.io.ByteArrayInputStream bai=new ByteArrayInputStream
(xml.getBytes());
Log.d(LOGTAG,"xml conttent"+xml);
//ByteArrayEntity bae=new
ByteArrayEntity(xml.getBytes());
StringEntity se=new StringEntity(xml,HTTP.UTF_8);
//FileEnity fe=new FileEnity();
// FileEntity fe=new FileEntity(new
File("/sdcard/test.xml"),"text/
xml");
method.setEntity(se);
} catch (Exception e) {
Log.d(LOGTAG,e.toString());
}
execute(client, method);
i think do a post request with http form is very difference as
psot a xml to server
so i test three Entity setEntity(),
ByteArrayEntity,StringEntity,FileEntity, but all failed .
can give me some code snopshot how to post a xml to server or can
google calendar api runs at android platform?
all above the code runs at android sdk1.5.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---