Question

I am having issues sending a POST via my module.

In my browser's REST client I get a 200 with

POST https://mydomain.com 
username=myuser&password=password1

So I know that the service is working fine. I tried to replicate this call in my Drupal module with

$url = "https://mydomain.com";
$data = array(
    'username' => 'myuser',
    'password' => 'password1',
);

$data = http_build_query($data, '', '&');
$options = array(
  'method' => 'POST',
  'data' => $data
);

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

The response I get is a 400. according to this I am not constructing the request correctly.

Question: How should I change my code in order to get a 200?

Note: I am using Drupal 7.

Thanks.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange
scroll top