Monday, March 9, 2015
Making Google Calendar Applications Faster Partial Response and Update
We recently launched the partial response and update feature for the Google Calendar Data API. Partial response and update allows you to request and update feeds containing only the elements that you’re interested in.
To request a partial response, you’ll need to add the fields query parameter to the end of the feed URL.
Request:
GET http://www.google.com/calendar/feeds/example@google.com/private/full?fields=entry(title,gd:when)Response:
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:gd="http://schemas.google.com/g/2005">
<entry>
<title type="text">Example meeting</title>
<gd:when endTime="2010-03-25T09:00:00.000-07:00" startTime="2010-03-25T08:00:00.000-07:00">
<gd:reminder method="alert" minutes="10"/>
<gd:reminder method="sms" minutes="10"/>
</gd:when>
</entry>
... more entries ...
</feed>
To partially update a feed, you simply need to modify the partial request with your updates and submit it back to the server using HTTP
PATCH
. The HTTP PATCH
method prompts for the requested changes to be applied to the resource defined by the request URL. To remove elements, partial updates can use the gd:field
attributes, which specifies elements to remove before merging with the target source. The example below updates the event title and time.Request:
PATCH http://www.google.com/calendar/feeds/default/private/full/eventID HTTP/1.1As you can see, the ability to partially request and update feeds greatly reduces the amount of data transferred, which is especially important in the mobile world.
Content-Type: application/xml
Host: www.google.com
GData-Version: 2
If-Match "FE8LQQJJeSp7IWA6WhVa"
<?xml version="1.0" encoding="UTF-8"?>
<entry>
<title type="text">Example meeting update</title>
<gd:when endTime="2010-03-27T10:00:00.000-07:00" startTime="2010-03-27T09:00:00.000-07:00">
<gd:reminder method="alert" minutes="10"/>
<gd:reminder method="sms" minutes="10"/>
</gd:when>
</entry>
For documentation on Google Calendar partial response and update, please refer to our Developer’s Guide.
We’ve also launched partial response and update for the YouTube Data API and Picasa Web Albums Data API and partial retrieval for the read-only Sidewiki Data API. For full details, please refer to our post on the Google Code Blog.
Posted by Peng Ying, Google Calendar API Team
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.