0
Отвечен

Force Content-Length in header

Wouter van der Post 3 года назад в Products / AV & Custom Systems обновлен Vladimir Ovchinnikov (expert) 3 года назад 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.

Image 42569

Can you tell me if there is another way to add "Content-Length":0 to the request header?

Отвечен

Hello.

Release 1.3.25 adds the ability to send a POST request with an empty BODY.

Сервис поддержки клиентов работает на платформе UserEcho