Cannot send drupal_http_request authorization header I'm trying to post a request using drupal_http_request, but my headers are causing authorization errors.

This is my request: 

$headers =  array('Authorization'=&gt;'Bearer [my token here]', 'Content-Type'=&gt;'application/json' );
$url = "https://api.ionic.io/push/notifications";
$message= new stdClass();
$message-&gt;message='That works';
$message-&gt;title='titleofmessage';
$data = array('tokens' =&gt; array('DEV-f765ac70-1bcb-4e0f-8bfd-adfd9612f185'), 'profile'=&gt;'fake_push_profile', 'notification'=&gt;$message);
$result=drupal_http_request($url, $headers, 'POST', json_encode($data));


In cURL it works fine, but I want to use drupal_http_request:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer [my token here]" -d '{"tokens": ["DEV-f765ac70-1bcb-4e0f-8bfd-adfd9612f185"],"profile": "fake_push_profile","notification": {"message": "That works", "title": "titleofmessage"}}' "https://api.ionic.io/push/notifications"


The error message I get is 'Authorization header is missing' so something seems to be happening to that header.

Any help much appreciated!
You have the second param to drupal_http_request wrong; it should be an array of options, not an array of headers. Headers is just one of those options.

To fix:

$result = drupal_http_request($url, array('headers' =&gt; $headers), 'POST', json_encode($data));