Forum: Ruby-Forum.com Problem in V3 search in yahoo shopping

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Db802d5fad77c1e4f9c14bef9b87865c?d=identicon&s=25 Asit Katiyar (asitk)
on 2007-09-21 11:36
Hi all,

I am trying to implement the yahoo shopping apis in my application. I am
trying to get the response using the XMLSimple. I am getting proper
result for the V1 and V2 product search. But V3 product search is not
working at all. Every time it give the error of "Invalid User Agent". My
code snippet is:

url =
URI.parse('http://api.shopping.yahoo.com/ShoppingService/V3/p...)
    appid = 'xxxxxxxxxx'
    post_args =
    {
      'appid' => appid,
      'department' => sindex,
      'query' => ipod,
      'start' => 1,
      'results' =>25,
    }
    xml_data = Net::HTTP.post_form(url,post_args).body
    data = XmlSimple.xml_in(xml_data)
    return data

and the error message I am getting is:

#<Net::HTTPOK:0x48be634>
<?xml version="1.0" encoding="utf-8"?>
<Error xmlns="urn:yahoo:api"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:yahoo:api
http://api.yahoo.com/Api/V1/error.xsd">
The following errors were detected:
<Message>User-agent not valid</Message>
</Error>

I also tried with appending the user agent string in the request url
like this:

'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1'

But It didn't work. Please help me sorting out this issue. It is
blocking the flow of the application.

Thanks in advance.
asitk
This topic is locked and can not be replied to.