I have an odd problem that i cannot seem to solve at all. We have a rest service that is supposed to accept submission data as a JSON object.

I have been going round in circles using curl. The command works with any service off the corporate network, and any EXTERNAL one when i use the curl proxy option but nothing is accessible (get or post) on the internal network. I always get a "false" comming back as response. Here is the PHP code:

---

```
$data_string =  "{\"fashionSignups\":[{\"corporateBrandId\":0,\"vendorId\":null,\"countryCode\":\"pt\",\"languageCode\":\"pt\",\"email\":\"test@ytDessddefwwt.com\",\"genderCode\":0,\"hasChildren\":0,\"zipcode\":\"12345\"}]}";
$ch = curl_init('http://xxx.xxx.com/fashionnewssignup');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
//curl_setopt($ch, CURLOPT_PROXY, "http://proxy.xxxx.com");
//curl_setopt($ch, CURLOPT_PROXYPORT, "8080");
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, CRED);

curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Content-Length: ' . strlen($data_string))
);
curl_setopt($ch, CURLOPT_TIMEOUT, 50);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 50);

//execute post
$result = curl_exec($ch);
echo "<pre>";
var_dump( curl_getinfo($ch) ) . '<br/>';
echo curl_errno($ch) . '<br/>';
echo curl_error($ch) . '<br/>';
//close connection
curl_close($ch);
var_dump ($result);
die;

```

---

and it's output:
----------------

```
array(26) {
  'url' =>
  string(59) "http://xxx.xxx.com/fashionnewssignup"
  'content_type' =>
  NULL
  'http_code' =>
  int(0)
  'header_size' =>
  int(0)
  'request_size' =>
  int(251)
  'filetime' =>
  int(-1)
  'ssl_verify_result' =>
  int(0)
  'redirect_count' =>
  int(0)
  'total_time' =>
  double(0.031)
  'namelookup_time' =>
  double(0)
  'connect_time' =>
  double(0.016)
  'pretransfer_time' =>
  double(0.016)
  'size_upload' =>
  double(0)
  'size_download' =>
  double(0)
  'speed_download' =>
  double(0)
  'speed_upload' =>
  double(0)
  'download_content_length' =>
  double(-1)
  'upload_content_length' =>
  double(-1)
  'starttransfer_time' =>
  double(0.031)
  'redirect_time' =>
  double(0)
  'redirect_url' =>
  string(0) ""
  'primary_ip' =>
  string(12) "XX.XX.XXX.12"
  'certinfo' =>
  array(0) {
  }
  'primary_port' =>
  int(1080)
  'local_ip' =>
  string(13) "XX.XX.XXX.196"
  'local_port' =>
  int(56107)
}
52<br/>Empty reply from server<br/>C:\xampp\htdocs\at\test.php:46:
bool(false)

Process finished with exit code 0

```

---

"Empty reply from server" 52 is what i get regardless of what URL i feed in. As i said above this code works fine off the network with other sites.

A git-bash curl gives this:

```
    curl -H "Content-Type: application/json" -X POST -d '{"fashionNewsSignups":[{"                                    corporateBrandId":0,"vendorId":null,"countryCode":"pt","languageCode":"pt","emai                                    l":"test@ytDessddefwwt.com","genderCode":0,"hasChildren":0,"zipcode":"12345"}]}'                                     http://xxx.xxx.com/fashionnewssignup
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   184    0     0  100   184      0   5935 --:--:-- --:--:-- --:--:-- 12266 
curl: (52) Empty reply from server

```

**The strange part is, when i try the same thing in JAVA on the same machine on the same network using this code, it works 100% fine, no proxy or anything required.**

This JAVA code works:

```
HttpClient httpClient = new DefaultHttpClient();

try {
    HttpPost request = new HttpPost("http://xxx.xxx.com/fashionnewssignup");
    StringEntity params =new StringEntity("{\"fashionSignups\":[{\"corporateBrandId\":0,\"vendorId\":null,\"countryCode\":\"pt\",\"languageCode\":\"pt\",\"email\":\"test@ytDessddefwwt.com\",\"genderCode\":0,\"hasChildren\":0,\"zipcode\":\"12345\"}]}");
    request.addHeader("content-type", "application/json");
    request.setEntity(params);
    HttpResponse response = httpClient.execute(request);
    String s = response.getStatusLine()+" " + response.toString();
    System.out.println(s);
}catch (Exception ex) {
    // handle exception here
} finally {
    httpClient.getConnectionManager().shutdown();
}

```

Anyone know what i am doing wrong? The service i am trying to access is written in JAVA if that is important :/