I'm using the following code to call the API to insert items:
private void PostData_Click(object sender, EventArgs e)
{
try
{
GBaseService service = new GBaseService("Google-
Tutorial-1.0", this.AppKey.Text.Trim());
GDataGAuthRequestFactory f = (GDataGAuthRequestFactory)
service.RequestFactory;
f.AccountType = "HOSTED_OR_GOOGLE";
service.RequestFactory = f;
service.setUserCredentials(this.Username.Text.Trim(),
this.Password.Text.Trim());
string token = service.QueryAuthenticationToken();
GBaseEntry entry = new GBaseEntry();
entry.Title.Text = "My House";
entry.Content.Content = "The best house of the area.";
entry.GBaseAttributes.ItemType = "Housing";
FloatUnit fProductPrice = new FloatUnit(25.00f,
"USD");
entry.GBaseAttributes.Price = fProductPrice;
entry.Links.Add(new AtomLink("http://
www.gatecrafters.com/product_detail_5045_5086.aspx"));
entry.GBaseAttributes.AddTextAttribute("listing_type",
"for sale");
entry.GBaseAttributes.AddTextAttribute("my attribute",
"hello");
entry.GBaseAttributes.AddFloatAttribute("bathrooms",
2f);
entry.GBaseAttributes.AddFloatAttribute("rooms",
6.5f);
entry.GBaseAttributes.AddFloatAttribute("bedrooms",
2f);
entry.GBaseAttributes.Location = "1600 Amphitheatre
Parkway, Mountain View, CA, 94043, USA";
//GBaseEntry myEntry = service.Insert(new Uri
(this.BaseUri.Text.Trim()), entry);
GBaseEntry myEntry = service.Insert
(GBaseUriFactory.Default.ItemsFeedUri, entry);
}
catch (GDataRequestException re)
{
MessageBox.Show(re.ToString());
if (re.ResponseString != null)
{
MessageBox.Show(re.ResponseString);
}
MessageBox.Show(re.Response.GetResponseStream
().ToString());
}
}
I'm sure my username and password are right. And I could get the
token. However, I got the Service not found exception after calling
the insert operation.
For the insert operation, if I use:
GBaseEntry myEntry = service.Insert(new Uri("https://
www.google.com/base/feeds/items"), entry);
Which is using https://www.google.com/base/feeds/items
I get null after calling the method, it does not throw any exceptions.
Could it be problem with my account on Google Base? Does it need any
activation or any other special action for the account?
Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Base 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-Base-data-API?hl=en
-~----------~----~----~----~------~----~------~--~---