QUERX TH: HTTP Push and wrong "Content-Lenght"



  • While testing the product QUERX TH we tried to configure the "http-push" to move the informations from the field to our IoT cloud in our development environment.

    During R&D, we:
    • upgraded the QUERX firmware to latest version 4.4.18.1
    • followed the instructions to build our own template to be able to add a dynamic access token
    • uploaded it on the product
    • successfully tested the POST to our web service

    The custom template is pretty simple:

    add=/tpl/j/cloud.tpl
    
    Authorization: Bearer {{pushtab_var1}}
    Content-Type: application/json; charset=utf-8
    { # # }
    {"{{sensortab_name.0}}": {"value": "{{sensortab_value.0}}", "unit":"{{sensortab_unit.0}}"}, "{{sensortab_name.1}}": {"value": "{{sensortab_value.1}}", "unit":"{{sensortab_unit.1}}"}}
    

    The issue we faced is that the posted content, whenever we are using a custom template, has an http header which is not following the web standards.

    As you can see in the following screenshot the “Content-Length” header of the POST request is always set to the value: -2

    test.jpg

    Problem is “-2” is not a standard value for that specific header (which should be >= 0) and we should break the standards to allow the web server to accept such information.

    We tried:

    • forcing the header from template
    • using a simple “Hello World” template
    • updating firmware to Querx TH 5.0.3.1

    but without success.

    Are we doing something wrong ?
    Is this a bug ?

    Any hint is much appreciated, thanks for your support!


  • Administrators

    Unfortunately there is an error in the english translation of the tutorial:
    The line with "{ # # }" should be replaced with "{# #}". This line marks the start of the http body and is used for calculating the content length. With the additional space characters it is not recognized and the content length is wrong. The following template should work:

    add=/tpl/j/cloud.tpl
    
    Authorization: Bearer {{pushtab_var1}}
    Content-Type: application/json; charset=utf-8
    {# #}
    {"{{sensortab_name.0}}": {"value": "{{sensortab_value.0}}", "unit":"{{sensortab_unit.0}}"}, "{{sensortab_name.1}}": {"value": "{{sensortab_value.1}}", "unit":"{{sensortab_unit.1}}"}}
    


  • @tim Thank you very much for your feedback!

    I can confirm everything work with the corrected template.


Log in to reply