drupal_http_request with basic authorization receives 401 response
If you're using Drupal 7, then I'm fairly certain you're supposed to put everything after the URL into a single options array instead of positional arguments. This was done so you can pass some arguments without passing all of the preceding ones.

https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_http_request/7

drupal_http_request($url, array(
  'headers' =&gt; $headers,
  'method' =&gt; 'POST',
  'data' =&gt; http_build_query($data)
));


should work.