0

I'm trying to insert some data into my merchant account data feed using the Content API. Using the code below, I've been given a "POST requests require a Content-length header. That’s all we know." error, but I've set the content length, so I'm really confused.

One theory I have is that it doesn't know where to put these requests, under my merchant account ID, I have two data feeds, and I'm not sure how to set it to enter into a given data feed.

The XML is stolen from here: https://developers.google.com/shopping-content/batch-operations

@feed = '<?xml version="1.0"?>
    <feed xmlns="http://www.w3.org/2005/Atom"
        xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/"
        xmlns:g="http://base.google.com/ns/1.0"
        xmlns:batch="http://schemas.google.com/gdata/batch">

    <entry xmlns="http://www.w3.org/2005/Atom"
        xmlns:sc="http://schemas.google.com/structuredcontent/2009"
        xmlns:scp="http://schemas.google.com/structuredcontent/2009/products"
        xmlns:app="http://www.w3.org/2007/app">
        <batch:operation type="INSERT"/>
        <title>Switch 1</title>
        <content type="text">A new item available...</content>
        <link rel="alternate" type="text/html" href="http://www.example.com/sku123"/>
        <sc:id>SKU123</sc:id>
        <sc:content_language>en</sc:content_language>
        <sc:target_country>US</sc:target_country>
        <scp:google_product_category>Electronics  &gt; Networking  &gt; Hubs  &amp;
        Switches</scp:google_product_category>
        <scp:condition>new</scp:condition>
        <scp:price unit="USD">25</scp:price>
        <scp:availability>in stock</scp:availability>
    </entry>


    <entry xmlns="http://www.w3.org/2005/Atom"
    xmlns:sc="http://schemas.google.com/structuredcontent/2009"
    xmlns:scp="http://schemas.google.com/structuredcontent/2009/products"
    xmlns:app="http://www.w3.org/2007/app">
      <batch:operation type="INSERT"/>
      <title>Switch 2</title>
      <content type="text">Another item available...</content>
      <link rel="alternate" type="text/html" href="http://www.example.com/sku124"/>
      <sc:id>SKU124</sc:id>
      <sc:content_language>en</sc:content_language>
      <sc:target_country>US</sc:target_country>
      <scp:google_product_category>Electronics  &gt; Networking  &gt; Hubs  &amp;
    Switches</scp:google_product_category>
      <scp:condition>new</scp:condition>
      <scp:price unit="USD">50</scp:price>
      <scp:availability>in stock</scp:availability>
     </entry>

    </feed>'


    http = HTTPClient.new
    @output = http.post('https://content.googleapis.com/content/v1/<myMerchantID>/items/products/schema/batch', {},"content"=> @feed, "Content-length"=>@feed.length.to_s, "GData-Version"=> "1", "Authorization" => "AuthSub token=myToken", "Content-Type"=> "application/atom+xml")

1 Answer 1

0

Are you Authenticating prior to your post?

https://developers.google.com/shopping-content/getting-started/authentication

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.