how to debug drupal_http_request I'm working on a module that takes a form submission and posts it to a rest api, using the webform validator module's hooks.  I'm trying to debug what's going wrong, and I have the following code, which correctly displays $data and $url but nothing for $result (I'm assuming it's null?).

I'm new to drupal and I wonder what I'm doing wrong, with the http_request that it comes back null, or what else I can do to debug.

      $options = array( data =&gt; $data,
                        method =&gt; 'POST');
      //verify $data
      $errors['item_2'] = $data;
      $errors['item_3'] = $url


      $result = drupal_http_request($url, $options);


      // display the returned JSON result as a form error
      $errors['item_1'] = json_decode($result);
drupal_http_request doesn't just return the response data, it returns an object.

Return value

object An object that can have one or more of the following components:

request: A string containing the request body that was sent.
code: An integer containing the response status code, or the error code if an error occurred.
protocol: The response protocol (e.g. HTTP/1.1 or HTTP/1.0).
status_message: The status message from the response, if a response was received.
redirect_code: If redirected, an integer containing the initial response status code.
redirect_url: If redirected, a string containing the URL of the redirect target.
error: If an error occurred, the error message. Otherwise not set.
headers: An array containing the response headers as name/value pairs. HTTP header names are case-insensitive (RFC 2616, section 4.2), so for easy access the array keys are returned in lower case.
data: A string containing the response body that was received.  

For example, you can check

// This is the actual response data.
drupal_set_message($result-&gt;data);
// if there's an error, it'll  be in here
drupal_set_message($result-&gt;error);


or, if using the devel module

dpm($result);


In your case, you might just need:

if (empty($result-&gt;error) {
  $errors['item_1'] = json_decode($result-&gt;data);
}else{
  // An error occurred, log, show msg etc...
}