Ready to get started?

Use Updategrams with Google Sheets Data



You can use updategrams to insert, update, and delete Google Sheets data. This guide shows how to use the CData BizTalk Adapter for Google Sheets to generate updategram schemas and instances.

In this article, you will create updategrams that can be executed by the CData BizTalk Adapter for Google Sheets. You will design a schema and use it as a template for generating insert, update, and delete updategrams.

Add the Adapter for Google Sheets to Your Project

Use the Add Adapter wizard to add the adapter to a BizTalk Server project in Visual Studio. You will use the adapter to query Google Sheets for metadata about the table you want to modify.

  1. Right-click on the project in the Solution Explorer and click Add -> Add Generated Items.
  2. Select Add Adapter Metadata in the resulting dialog box.
  3. In the resulting Add Adapter Wizard, select the CData BizTalk Adapter for Google Sheets from the list view.
  4. In the Port menu, leave the selection blank. Or, select a receive location or send port that has been configured to use the adapter.
  5. When you click Next, the Schema Wizard is displayed.

Generate a Schema for an Updategram

Follow the steps below to create a schema in a BizTalk Server project in Visual Studio.

  1. If you have not already done so, add the Google Sheets adapter to your project.
  2. On the Connection String page of the Add Adapter wizard, enter authentication credentials and other connection properties, if they were not already configured in the send port or receive location. Below is a typical connection string: Spreadsheet=MySheet;InitiateOAuth=GETANDREFRESH

    You can connect to a spreadsheet by providing authentication to Google and then setting the Spreadsheet connection property to the name or feed link of the spreadsheet. If you want to view a list of information about the spreadsheets in your Google Drive, execute a query to the Spreadsheets view after you authenticate.

    ClientLogin (username/password authentication) has been officially deprecated since April 20, 2012 and is now no longer available. Instead, use the OAuth 2.0 authentication standard. To access Google APIs on behalf on individual users, you can use the embedded credentials or you can register your own OAuth app.

    OAuth also enables you to use a service account to connect on behalf of users in a Google Apps domain. To authenticate with a service account, you will need to register an application to obtain the OAuth JWT values.

    See the Getting Started chapter in the help documentation to connect to Google Sheets from different types of accounts: Google accounts, Google Apps accounts, and accounts using two-step verification.

    See the "BizTalk Configuration" chapter in the help documentation for more information on the required connection properties.

  3. On the Schema Information page, click Send Port in the General Options section. Select Updategram from the CommandType menu. If you are using the adapter in a solicit-response send port, disable the One-Way option.
  4. On the next page, Statement Information, select the type of the updategram: Insert, Update, or Delete. Select the Table name and the columns you want to include in the schema. If you want to update or delete, the Id column is required.

    Note: When you create the updategram, you are limited to modifying the columns you include in the schema.

  5. Click Next to view a summary of the schema and finish the wizard to create the schema. The resulting .xsd file is added to your project.

Generate Insert, Update, and Delete Instance Messages

After you create the updategram schema, you can use the .xsd file to generate the updategram: Right-click the .xsd file and select Generate Instance. You can also use this file as a template to manually create updategrams. Below are example generated updategram instances for inserts, updates, and deletes:

Insert

An example of INSERT is below. In this instance, there is only an after block, which specifies how the data will change.

<ns0:parameters xmlns:ns0="http://www.cdata.com/GoogleSheetsProvider"> <ns0:sync> <ns0:before></ns0:before> <ns0:after> <ns0:Orders Shipcountry="Shipcountry_0" OrderPrice="OrderPrice_1" /> </ns0:after> </ns0:sync> </ns0:parameters>

Update

An example of UPDATE is below. In this instance, there is both a before block (how the data currently exists in the table) and an after block (how the data will change).

<ns0:parameters xmlns:ns0="http://www.cdata.com/GoogleSheetsProvider"> <ns0:sync> <ns0:before> <ns0:Orders Id=https://spreadsheets.google.com/feeds/list/tv3a8NcMPGTad5D56PRtuVQ/oda/private/full/cokwr></ns0:Orders> </ns0:before> <ns0:after> <ns0:Orders Shipcountry="Shipcountry_0" OrderPrice="OrderPrice_1" ></ns0:Orders> </ns0:after> </ns0:sync> </ns0:parameters>

Delete

An example for DELETE is below. The after block will be empty to show that it is removing the item.

<ns0:parameters xmlns:ns0="http://www.cdata.com/GoogleSheetsProvider"> <ns0:sync> <ns0:before> <ns0:Orders Id=https://spreadsheets.google.com/feeds/list/tv3a8NcMPGTad5D56PRtuVQ/oda/private/full/cokwr></ns0:Orders> </ns0:before> <ns0:after></ns0:after> </ns0:sync> </ns0:parameters>

Processing Schemas

To use updategrams to insert, update, or delete Google Sheets records, see the tutorial.