English | Site Directory

Google Base Data API

Accessing the Google Base data API using VB.NET

The example VB.NET application shows how to use VB.NET to perform batch operations in Google Base.

The application builds a standard .NET form that contains a datagrid. It fills this grid with Atom data from Google Base feeds, including author, title, content, and content_type.

End users can edit or delete existing data and insert new data via the data grid. Once they are done making modifications, the application uses batch operations to perform all of the updates at once.

Running the application

To run the example application on a Windows machine, navigate to the lib/Release directory of the C# Client Package and run gbase_demo.exe. This must be run from a local file system; it will not work on a shared network drive.

Retrieving your Google Base data

To log in, enter the following information in the fields:

Username: the Google login that you use to access your http://base.google.com/ account.

Password: the associated password

Applicationkey: your developer key. If you don't already have one, you can get one on the signup page.

Googlebase URI: the URI of the feed you wish to access. The default value of http://base.google.com/base/feeds/items accesses the data in your Items feed.

Once you have specified this information, click Get the data... to download the Google Base data from the specified feed into the application.

Modifying your Google Base data

You can modify an existing entry, delete an existing entry, or add a new entry. If you add a new entry, do not specify the item ID. Click Post the data to post your modifications to your Google Base account.

Understanding the code

You can find the source code for the example application in the samples/gbase/demo directory of the C# Client Package.

The main implementation file is Form1.vb.

The beginning of the application builds the form, then handles entry of the username, password, webkey and URI.

Once the user enters login information and clicks the Get the data... button, the GetData_Click() method is executed. GetData_Click() gets the Google Base Feed, creates a DataTable object, and fills that table with data from the feed. Then, Me.BaseGrid.DataSource is set to this table object so that the grid shows the data. The functionality for editing the table is build in to .NET.

When the user is ready to send his data to the server, he clicks the Post the data button. At that point, the PostData_Click() method is executed. PostData_Click() walks over the table and identifies rows which have been changed, deleted, or inserted. For each of those rows, it creates an entry in a BatchFeed. If the entry was edited, it removes the original entry from the array Me.entryArray. When the walk over the table is complete, the BatchFeed is completed, and it is submitted to the user-specified batch URI.

In order to simplify the code, the application doesn't implement any real error handling. It only displays the text "errors encountered" if the feed returns errors.