3 messages in com.googlegroups.google-base-data-apiRe: Question - Google Base Data C# AP...| From | Sent On | Attachments |
|---|---|---|
| Sean | 28 May 2008 10:07 | |
| Frank Mantek | 28 May 2008 10:19 | |
| Sean | 28 May 2008 14:25 |
| Subject: | Re: Question - Google Base Data C# API Oddities![]() |
|---|---|
| From: | Sean (sean...@gmail.com) |
| Date: | 05/28/2008 02:25:06 PM |
| List: | com.googlegroups.google-base-data-api |
Hi Frank, thanks for responding.
I changed the Type property of the Content to "xhtml" and that worked pretty good, except now the process is crashing after about 8 items... is it possible that the code is too fast for the service?
On May 28, 1:19 pm, Frank Mantek <fman...@gmail.com> wrote:
The placing of the namespace declaration is more "wasteful", but syntactically not wrong.
It would help if you can let us know if there is any additonal info in the 400 return. You can evaluate the ResponseString property of the thrown exception, or use Fiddlertool to check this out. One thing that comes to mind is that the Content is not marked as xhtml ... ?
Frank Mantek Google On May 28, 2008, at 7:08 PM, Sean wrote:
Greetings! I am trying to develop a console application in Visual Studio that references the Google Base API DLLs. This app will read rows from a SQL Server view and for each row in the view, populate an IList of objects that are then passed to a function that creates a GBaseEntry for each item in the IList. After the GBaseEntry is created, it is Inserted to the feed.
I was originally receiving a 400 error on the submit so I tried to do some debugging and here are the highlights of the debugging... Here is the code so far:
//I've noticed it doesn't matter what I put in the appName parameter here.... Is that true? GBaseService service = new GBaseService("Google- Tutorial-1.0", key); service.setUserCredentials(username, password);
//A ProductEntry is a simple container class that has private and public strings with gets/sets foreach (ProductEntry pe in entries) { GBaseEntry entry = new GBaseEntry();
entry.Title.Text = pe.ProductName + " - " + pe.ProductShortDesc; entry.Content.Content = "Category: " + pe.CategoryName + ". " + pe.ProductLongDesc; entry.GBaseAttributes.ItemType = ITEM_TYPE; entry.GBaseAttributes.AddTextAttribute("Brand", pe.ManufacturerName); entry.GBaseAttributes.AddTextAttribute("mpn", pe.LegacyId); FloatUnit price = new FloatUnit(pe.Price + " usd"); entry.GBaseAttributes.Price = price;
if (!string.IsNullOrEmpty(pe.ImageUrl))
entry.GBaseAttributes.GetUrlAttribute(pe.ImageUrl);
entry.GBaseAttributes.AddTextAttribute("condition", "new"); entry.GBaseAttributes.DeliveryNotes = "Standard or Express"; entry.GBaseAttributes.AddTextAttribute("model number", pe.ProductName); XmlTextWriter writer = new XmlTextWriter(Console.Out); entry.SaveToXml(writer); Console.Out.Flush(); /*Here's the XML at this point after the flush: <entry xmlns="http://www.w3.org/2005/Atom"> <g:item_type type="text" xmlns:g="http://base.google.com/ns/ 1.0">products</g:item_type> <g:Brand type="text" xmlns:g="http://base.google.com/ns/1.0">Briggs & Stratton</g:Brand> <g:mpn type="text" xmlns:g="http://base.google.com/ns/1.0">100524GS</ g:mpn> <g:price type="floatUnit" xmlns:g="http://base.google.com/ns/ 1.0">7.65 usd</g:price> <g:condition type="text" xmlns:g="http://base.google.com/ns/ 1.0">new</g:condition> <g:delivery_notes type="text" xmlns:g="http://base.google.com/ns/ 1.0">Standard or Express</g:delivery_notes> <g:model_number type="text" xmlns:g="http://base.google.com/ns/ 1.0">Deck Wash</g:model_number> <title type="text">Deck Wash - 100524GS</title> <content type="text"> Category: Accessories. <p> <font face="Tahoma"> 32 fl. oz. (946ml) - Concentrated Deck Wash </font> </p> <p> <font face="Tahoma">Makes 4 gallons of cleaner</font> </p> </content> </entry>
This looks a little different from this sample entry in the demo page:
<?xml version='1.0'?> <entry xmlns='http://www.w3.org/2005/Atom' xmlns:g='http://base.google.com/ns/1.0'> <author> <name>Jane Doe</name> <email>Jane...@gmail.com</email> </author> <title type="text">Marie-Louise's chocolate butter</title> <content type="xhtml"> <b>Ingredients:</b> <ul> <li>250g margarine,</li> <li>200g sugar,</li> <li>2 eggs, and</li> <li>approx. 8 tsp cacao.</li> </ul> <p>Mix everything. Heat while stirring, but do not allow the mix to boil. Put in a container and cool in fridge.</p> </content> <g:item_language type="text">en</g:item_language> <g:item_type type="text">testrecipes</g:item_type> <g:cuisine type="text">danish</g:cuisine> <g:cooking_time type="intUnit">10 minutes</g:cooking_time> <g:main_ingredient type="text">cacao</g:main_ingredient> <g:main_ingredient type="text">margarine</g:main_ingredient> <g:serving_count type="int">4</g:serving_count> </entry> .
The most notable of these differences being the xmlns:g="http:// base.google.com/ns/1.0" attribute in each gbaseattribute. The xmlns:g element is NOT in the entry element. The title and content elements are out of order but other then that don't seem to be incorrect. */ GBaseEntry myEntry = service.Insert(GBaseUriFactory.Default.ItemsFeedUri, entry); }
After the code reaches this point the follow error is kicked out to the console:
Unhandled Exception: Google.GData.Client.GDataRequestException: Execution of request failed:http://www.google.com/base/feeds/items ---> System.Net.WebException: The remote server returned an error: (400) Bad Request. at System.Net.HttpWebRequest.GetResponse() at Google.GData.Client.GDataRequest.Execute() --- End of inner exception stack trace --- at Google.GData.Client.GDataRequest.Execute() at Google.GData.Client.GDataGAuthRequest.Execute(Int32 iRetrying) at Google.GData.Client.Service.StreamInsert(Uri feedUri, AtomBase baseEntry, GDataRequestType type) at Google.GData.Client.Service.Insert(Uri feedUri, AtomEntry newEntry) at Google.GData.GoogleBase.GBaseService.Insert(Uri feedUri, GBaseEntry entry) at GoogleBase.ProductSubmission.SubmitNewProducts(String username, String password, IList`1 entries, String appName, String key) in D:\Working Folders\CLIENT\client\GoogleBase \ProductSubmission.cs:line 51 at Google_Base_Uploader.Program.Main(String[] args) in D:\Working Folders\CLIENT\client\Google Base Uploader\Program.cs:line 48
I'd appreciate any insight on what's happening here, thank you for your time.
--~--~---------~--~----~------------~-------~--~----~
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 Goog...@googlegroups.com
To unsubscribe from this group, send email to
Goog...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/Google-Base-data-API?hl=en
-~----------~----~----~----~------~----~------~--~---




