Can someone help me with the domainr JSON API?
I am trying to implement domainr JSON api into my Ruby on Rails application. But when I try to send a GET request to the service it returns back an empty object.
Here's what I am writing
url = URI.parse('http://domai.nr/api/json/search?q=domainr')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
and here is what I get back
{\"query\": \"\", \"results\": [], \"error\": {\"status\": 404, \"message\": \"No results found.\"}}
Can anyone throw some light on this? Where am I going wrong? Thanks for any help in advance.
Here's what I am writing
url = URI.parse('http://domai.nr/api/json/search?q=domainr')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
and here is what I get back
{\"query\": \"\", \"results\": [], \"error\": {\"status\": 404, \"message\": \"No results found.\"}}
Can anyone throw some light on this? Where am I going wrong? Thanks for any help in advance.
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
-
Inappropriate?Ruby's Net::HTTP requires that you send url.query specifically. Check out the Readme in the RDoc and you should be able to figure it out.
I’m Rubyish
1 person says
this answers the question
-
Inappropriate?Hey,
Thanks for the reply.
It worked with the following code
url = URI.parse(requrl)
res = Net::HTTP.get_response(url)
result=JSON.parse(res.body, {})
I simply used get_response method instead of dong Get::new and the using start .. pretty silly .. Thanks anyways
Regards
M
I’m feeling silly!!!
Loading Profile...



EMPLOYEE