6 messages in com.googlegroups.google-base-data-apiRe: Cant get xml errors from 400 Bad ...| Subject: | Re: Cant get xml errors from 400 Bad Request using php and curl trouble inserting item![]() |
|---|---|
| From: | aspirion (aspi...@gmail.com) |
| Date: | 01/16/2008 11:52:01 PM |
| List: | com.googlegroups.google-base-data-api |
Wow I'm at a loss for words but for some reason the update is working all of a sudden. I can't remember if I made this change before or after posting here but I've noticed that I commented out the line: [// $result .= "<category scheme='http://base.google.com/categories/ itemtypes'" . " term='Products'/>" . "\n";] in my code, which came from google's sample code. The only other thing i did was put the [$result .= "<g:item_type>products</g:item_type>" . "\n";] line of code up at the top. Perhaps one of those two things made the difference, or maybe my item needed to be approved before I could update it, whatever the reason I'm just happy it works now. On a side note you wouldn't be able to tell me how to do a packet trace would you, for future references?
In case your curious anyways or if someone wants a good example or working xml hers the xml I finally got to work:
<?xml version='1.0'?> <entry xmlns='http://www.w3.org/2005/Atom' xmlns:g='http:// base.google.com/ns/1.0'> <g:item_type>products</g:item_type> <title type='text'> Advion Fire Ant Bait </title> <content> Why settle for partial control when you can control the entire colony? Advion Fire Ant Bait controls the entire colony of fire ants, pavement ants, or big-headed ants in just 24 to 74 hours. In addition, Advion is the ideal choice for broadcast applications or for treating fire ant mounds directly. </content> <g:id> 3 </g:id> <g:brand> DuPont </g:brand> <g:capacity> 1.333 Acres </g:capacity> <g:feature> active ingredient Indoxacarb .045%, targets Imported fire ants, Bigheaded ants, and Pavement ants. </g:feature> <g:functions> fire ant bait </g:functions> <g:price> 52.95 usd </g:price> <g:product_type> bait </g:product_type> <g:recommended_usage> For use in Residential lawns, golf courses, recreational areas, industrial sites and other similar areas where imported fire ants, bigheaded ants and pavement ants are found. </ g:recommended_usage> <g:size> 2 lb jar </g:size> <g:weight> 2 lb </g:weight> </entry>
Thanks anyways though
On Jan 16, 5:11 pm, Jeff S <j....@google.com> wrote:
Could I see the XML that you are sending for your item when you make the Put request? A packet trace from ethereal/wireshark would be ideal.
Thank you,
Jeff
On Jan 14, 4:54 pm, aspirion <aspi...@gmail.com> wrote:
Also I forgot when posting this to remove //print_r(get_object_vars($item)); and ini_set("display_errors", true); error_reporting(E_ALL^E_NOTICE); from my code. These are lines of code i used to try to narrow down the problem but didn't help me at all. They also do not change the funtionality of the code, it runs the same with or without them. Any help would be very appreciated.
On Jan 14, 7:43 pm, aspirion <aspi...@gmail.com> wrote:
Hi all, so far i am able to insert items into google base but not update them. It is specifically infuriating as i am using the exact same code from the php recipe example taken off the google base apis website. When i use the recipe program it works, but the one ive modified for inserting my own products does not. This is the code im currently using function updateItem($item) { $ch = curl_init(); /* Create a CURL handle. */
/* Prepare the data for HTTP PUT. */ //print_r(get_object_vars($item)); $putString = $this->buildInsertXML($item); print_r($putString); $putData = tmpfile(); fwrite($putData, $putString); fseek($putData, 0);
/* Set cURL options. */ curl_setopt($ch, CURLOPT_URL, $item->item_link); curl_setopt($ch, CURLOPT_PUT, true); curl_setopt($ch, CURLOPT_INFILE, $putData); curl_setopt($ch, CURLOPT_INFILESIZE, strlen($putString)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $this->headers);
ini_set("display_errors", true); error_reporting(E_ALL^E_NOTICE); $result = curl_exec($ch); /* Execute the HTTP request. */ if (curl_errno($ch)) { die(curl_error($ch)); } else { curl_close($ch); fclose($putData); } return $result; } $item is from a googleItem class ive created to store the attributes, the xml is built off these values.i also know that the xml is at least good enough to insert but not to update. The error returned is very non-specific: "400: Bad Request" so i am troubled as to what the issue is here. Considering the recipe version google supplies works and mine is a near exact replica i believe the code is fine and the problem lies in the xml. Ive noticed that others have received xml errors inside a <errors> tag, but i have not found anyone using php who is able to replicate this. Please Help!!




