0
Answered
Force Content-Length in header
Wouter van der Post 5 years ago
in Products / AV & Custom Systems
•
updated by Vladimir Ovchinnikov (expert) 5 years ago •
1
Hello,
The webserver (API) I am calling from iRidium requires the Content-Length header to be present. Even a value of '0' is OK, as long as the header property is in the request.
If I execute the following:
IR.GetDevice("Custom AV").SendEx({
Type: "POST",
Url: "/api/v1/sp/1/1,
Headers: {"Content-Type":"application/json", "X-Api-Key":"somekey"},
cbReceiveCode:
function(code) {
if (code != 200) {
IR.Log("Error response (" + code + ") received");
}
},
cbReceiveText:
function(text, code, headers) {
if (code != 200) {
IR.Log("Error response (" + code + ") received\r\nDetails: " + text);
}
}
});There is no Content-Length header in the request.
I tried to force it by adding an empty data object:
var data = "";
IR.GetDevice("Custom AV").SendEx({
Type: "POST",
Url: "/api/v1/sp/1/1,
Data: [data],
Headers: {"Content-Type":"application/json", "X-Api-Key":"somekey"},
cbReceiveCode:
function(code) {
if (code != 200) {
IR.Log("Error response (" + code + ") received");
}
},
cbReceiveText:
function(text, code, headers) {
if (code != 200) {
IR.Log("Error response (" + code + ") received\r\nDetails: " + text);
}
}
});But this also does not add the header.
According to the documentation I can't add this property to the Header field.

Can you tell me if there is another way to add "Content-Length":0 to the request header?
Customer support service by UserEcho
Hello.
Release 1.3.25 adds the ability to send a POST request with an empty BODY.