1

Within "install plugins" I'm receiving an error stating "An Unexpected HTTP Error occurred during the API request." When I do a plugin search it throws me back to my site's 404 page. Any idea what would prevent my site from syncing properly with WordPress's servers?

enter image description here

I added Hameedullah's code to functions.php and recevied this returned object(WP_Error)#21 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(75) "Could not resolve host: api.wordpress.org; No data record of requested type" } } ["error_data"]=> array(0) { } }

Is this a curl transport issue?

7
  • 2
    have you tried enabling debug mode and see if any PHP errors are shown?
    – Scott
    May 18 '11 at 14:42
  • I haven't, are you using a plugin? May 18 '11 at 14:56
  • 1
    Here is how to enable debug
    – Scott
    May 18 '11 at 15:07
  • Wow, so I used debug and the return was terrifying. I'm not sure even where to begin here. I don't see anything related to the plugin section of the site. pastebin.com/vrnk0ER0 May 18 '11 at 16:13
  • All those errors are notices and and wouldn't cause a HTTP error
    – Scott
    May 18 '11 at 16:24
3

You can use the following code to dump the HTTP Api response, will help you figure out the cause of error.

function dump_http_api_response($response, $type="", $transport=null ) {
    if ( $type == "response" )
        var_dump ( $response );
}
add_action('http_api_debug', 'dump_http_api_response', 1, 3);

Example Output:

object(WP_Error)#15 (2) { ["errors"]=> array(1) { ["http_request_failed"]=> array(1) { [0]=> string(41) "Couldn't resolve host 'api.wordpress.org'" } } ["error_data"]=> array(0) { } }
4
  • Thanks Hameedullah, what should I be looking for as a result? May 18 '11 at 16:13
  • 1
    In case of error 99.9% chances are the $response will be a WP_Error object. I am updating my answer to show the example dump. I have also made minor adjustment to add_action call to include priority and expected number of arguments. May 18 '11 at 16:24
  • That worked, I've updated my post with the return. May 18 '11 at 16:37
  • This ultimately solved my issue. The problem was Windows had dropped the gateway which was preventing WordPress from accessing anything externally. May 18 '11 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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