GET requests are functioning properly.
PUT requests made from the API Debug tool are also working correctly.
However, both PUT and POST requests, regardless of the data or API URL used, are resulting in the following error:
example:
OPTIONS net::ERR_EMPTY_RESPONSE
These requests are returning null responses.
Below is the relevant Angular JS code:
var bridgeIp = "http://xxx.xxx.x.x";
var username = "authenticatedUsername";
var lightData = {"on": true};
$http.put(bridgeIp+"/api/"+username+"/lights/5/state", lightData)
.then(function success(response) {
console.log(response.data);
}, function error(e){
console.log(e);
});
I have also attempted to use jQuery's Ajax function and encountered the same issue.
I tried to compare the requests using Fiddler, but faced a CORS error. Subsequently, I compared the requests with Charles, and here are the results:
From API Debug Tool:
URL http://xxx.xxx.x.x/api/AuthorizedUser/lights/5/state
Status Complete
Response Code 200 OK
Protocol HTTP/1.1
SSL -
Method PUT
Kept Alive No
Content-Type application/json
Client Address /127.0.0.1
Remote Address xxx.xxx.x.x/xxx.xxx.x.x
Timing
Request Start Time 3/23/16 18:24:17
Request End Time 3/23/16 18:24:17
Response Start Time 3/23/16 18:24:17
Response End Time 3/23/16 18:24:17
Duration 43 ms
DNS 0 ms
Connect 2 ms
SSL Handshake -
Request 2 ms
Response 1 ms
Latency 37 ms
Speed 20.46 KB/s
Response Speed 879.88 KB/s
Size
Request Header 427 bytes
Response Header 421 bytes
Request 12 bytes
Response 41 bytes
Total 901 bytes
Request Compression -
Response Compression -
From my HTTP request through JavaScript:
URL http://xxx.xxx.x.x/api/AuthorizedUser/lights/5/state
Status Failed
Failure Remote server closed the connection before sending response header
Response Code -
Protocol HTTP/1.1
SSL -
Method OPTIONS
Kept Alive No
Content-Type -
Client Address /127.0.0.1
Remote Address xxx.xxx.x.x/xxx.xxx.x.x
Timing
Request Start Time 3/23/16 18:24:55
Request End Time 3/23/16 18:24:55
Response Start Time -
Response End Time 3/23/16 18:24:55
Duration 14 ms
DNS 0 ms
Connect 2 ms
SSL Handshake -
Request 2 ms
Response -
Latency -
Speed 31.74 KB/s
Response Speed -
Size
Request Header 455 bytes
Response Header -
Request -
Response -
Total 455 bytes
Request Compression -
Response Compression -
Any assistance with this issue would be highly appreciated.