I want to use Sketchup http request for my plugin.
Url is http://testapi.sentiovr.com/api/v1/sentio/plans
When I am hitting it on browser I’m getting a response
{“error”:“Api key is missing”}
But when I’m executing it through sketchup api. Status code is 0 and body is empty
request = Sketchup::Http::Request.new('http://testapi.sentiovr.com/api/v1/sentio/plans', Sketchup::Http::GET)
request.start do |request, response|
puts "Sentio http status code: #{response.status_code} body #{response.body}."
end
I could not get a lot of debug info from SketchUp’s HTTP API, but you can still try different implementations to see if something is wrong with your request (irb with “net/http” or “open-uri”).
Your server is configured to redirect to https, which is a problem for some http libraries that don’t follow redirects (“301 Moved Permanently”).
Then when changing the url to https, ssl verification fails (even the browser gives “Invalid certificate” and wants me to confirm that).
Aerilius has you on the right track. Maybe this additional info will help: When a trusted web site, e.g. ‘http://www.houseofbread.org/’, is substituted for your link, the code works and produces the html body.
Your site is not trusted. Using the Chrome browser and just clicking on your link to ‘…/plans’, gives me this scary message:
Your connection is not private
Attackers might be trying to steal your information from testapi.sentiovr.com (for example, passwords, messages, or credit cards). …
NET::ERR_CERT_AUTHORITY_INVALID
…
This server could not prove that it is testapi.sentiovr.com; its security certificate is not trusted by your computer’'s operating system. This may be caused by a misconfiguration or an attacker intercepting your connection.
You mention that when you visit with the browser it says {“error”:“Api key is missing”}. This indicates that you are missing a parameter to the request.
You might want to also inspect the headers of the response.
That being said, when I visit the API url from Chrome I get a message the Chrome is denying the connection:
It appear to be redirecting to HTTPS and the certificate isn’t valid.
The Http classes uses Chromiums to perform the requests - so I’m guessing that might also cause the request to be denied here.