Skip to main content
Visitor II
January 20, 2019
Solved

SPW04SA - How to use additional headers in Http POST & GET requests

  • January 20, 2019
  • 2 replies
  • 1599 views

I'm using the SPW04SA module and want to write sensor data to the Azure Storage Table service. To achieve this I have to add special headers to my requests.

Until now I couldn't find out if/how this can be done using AT+S.HTTPPOST and AT+S.HTTPGET. As I understand the documentation I can use the files <in_filename> and <out_filename> to achieve this. However I couldn't find an advice, in which format the 'Custom http request" must be present in <out_filename>. (By the way: For the HTTPGET command the meaning of <in_filename> and <out_filename> seems to be swapped. The response body can be found in <in_filename>)

    This topic has been closed for replies.
    Best answer by Elio Cometti

    ​Hello,

    unfortunately specifying a custom header is not possible with HTTPGET/HTTPPOST commands, the customized HTTP GET/POST request must be sent over a regular TCP/TLS connection.

    About the last two parameters in HTTPGET command, you are right and the syntax is same as HTTPPOST command.

    Regards,

    Elio

    2 replies

    Visitor II
    January 22, 2019

    ​Hello,

    unfortunately specifying a custom header is not possible with HTTPGET/HTTPPOST commands, the customized HTTP GET/POST request must be sent over a regular TCP/TLS connection.

    About the last two parameters in HTTPGET command, you are right and the syntax is same as HTTPPOST command.

    Regards,

    Elio

    RoSchmiAuthor
    Visitor II
    January 22, 2019

    Thanks for your answer,

    but after some time I got it working as is shown in the following example.

    I used the X-NUCLEO-IDW04A1 Extension board and Teraterm

    How to:

    AT+S.FSD=myrequest      (delete possible old file myrequest)

    AT+S.FSC=/myrequest,61    (Create file myrequest in ram, expected 61 char) terminate with CR (not CRLF)

    paste with right mouse click:

    GET 192.168.1.71/index.html HTTP/1.1

    type CR on keyboard but make sure that teraterm sends CRLF

    paste with right mouse click:

    Accept-Language: en-us          (new and only header to be used)

    If I print the Ram file myrequest

    AT+S.FSP=myrequest,0,61

    I get:

    GET 192.168.1.71/index.html HTTP/1.1

    Accept-Language: en-us

    If I send the request with:

    AT+S.HTTPGET=192.168.1.71,,80,0,,,,myrequest

    On the other side (http server) I see:

    GET 192.168.1.71/index.html HTTP/1.1\r\nAccept-Language: en-us\r\n0\r\n\r\n

    So the header fields used as default are no longer there, the new header is there and a "dummy header" \r\n0\r\n

    is added by the firmware.

    I hope that this "dummy header" is simply neglegted by the servers I want to use.

    So the SPWF04SA Module and its firmware seem to be better as you think.

    By the way: Can we expect to see a successor in the next months or is STM going to leave this product line at all?

    Best regards

    RoSchmi

    Visitor II
    January 23, 2019

    ​Hello RoSchmi,

    I'm not sure your implementation will work as you expect with the Azure ST, since the "dummy header" might be part of the chunked encoding used to upload the data, unless it is a way of upgrading the HTTP protocol that I'm not aware of.

    Regarding your last request, I suggest to contact your dealer (distributor or ST Sales) to get details.

    Regards,

    Elio

    RoSchmiAuthor
    Visitor II
    January 23, 2019

    Thanks for your answer,

    I'll will give an information if I get the transmission to Azure Storage working.

    Regards

    RoSchmi