Can't select Bootswatch style. The message: ERROR: Unable to reach Bootswatch API. Please ensure the server your website is hosted on is able to initiate HTTP requests. Appears

Comments

valkum’s picture

Hmm should not be a bug, but to be sure. Are you getting update informations for modules?

markhalliwell’s picture

Assigned: alegreiff » Unassigned
Category: bug » support
Status: Active » Closed (works as designed)

Indeed, this is an explicitly defined error and only informs those when a sever cannot send an HTTP request and retrieve data. There is really nothing that we can do about this and has to be fixed on the server level (via PHP).

PascalAnimateur’s picture

Humm... I experience the same thing on both my dev and production sites...
@Mark Caver : what PHP configuration are you thinking about?

PascalAnimateur’s picture

Upon inspecting the issue, I discovered that http://api.bootswatch.com/3/ can't be reached even from the browser.. is this normal ?
The demo on bootswatch.com doesn't work either : http://bootswatch.com/help/#api

valkum’s picture

I can reach api.bootswatch.com/3/
It resolves to: af-us01-2-146473721.us-east-1.elb.amazonaws.com

PascalAnimateur’s picture

ping: unknown host api.bootswatch.com

Is this normal ? (I'm in Canada it that has anything to do with it)

markhalliwell’s picture

It could be that your ISP is blocking it. It could be that your server has safe_mode on? It could be... a number of things, I'm not entirely sure. Regardless, this "error" says exactly what it means: it cannot establish a connection to the Bootswatch API server. Here is my output:

[10-30 14:59] 0 processes
9.39 MB - ~
markcarver@Marks-MacBook-Air$ curl -I api.bootswatch.com
HTTP/1.1 200 OK
Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Age: 0
Content-length: 6846
Content-Type: application/json
Date: Wed, 30 Oct 2013 21:00:52 GMT
Server: nginx
Via: 1.1 varnish
X-Varnish: 1963488094
Connection: keep-alive
PascalAnimateur’s picture

That's really strange.. anyways thanks for the help.

I managed to get it working with the following line in /etc/hosts :
54.236.159.122 api.bootswatch.com

perohu’s picture

Here in Hungary a can't ping api.bootswatch.com neither, very strange...
I've edited the /etc/hosts too

vzsigmond’s picture

Issue summary: View changes

I can confirm the error, it's still present in 7.x-3.0.

In bootstrap/includes/settings.inc (line 433):

$request = drupal_http_request('http://api.bootswatch.com/3/');
  if ($request && $request->code === '200' && !empty($request->data)) {
    if (($api = drupal_json_decode($request->data)) && is_array($api) && !empty($api['themes'])) {
      foreach ($api['themes'] as $bootswatch_theme) {
        $bootswatch_themes[strtolower($bootswatch_theme['name'])] = $bootswatch_theme['name'];
      }
    }
  }

drupal_http_request() returns an integer as status code for the request. You are checking the type too and $request->code === '200' will be false. Update your if clause from $request->code === '200' to $request->code == 200 and it should work as designed! :-)

vzsigmond’s picture

Version: 7.x-3.0-rc2 » 7.x-3.0
Category: Support request » Bug report
Status: Closed (works as designed) » Needs review
markhalliwell’s picture

Version: 7.x-3.0 » 7.x-3.0-rc2
Category: Bug report » Support request
Status: Needs review » Closed (works as designed)
Related issues: +#2450757: Provide a more robust CDN solution

Do not change meta information on closed issues.

Also, this has already been addressed in the latest code: https://www.drupal.org/node/2452617