cancel
Showing results for 
Search instead for 
Did you mean: 

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

RoSchmi
Associate II

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>)

1 ACCEPTED SOLUTION

Accepted Solutions
Elio Cometti
Senior II

​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

View solution in original post

5 REPLIES 5
Elio Cometti
Senior II

​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

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

Elio Cometti
Senior II

​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

Thanks for your answer,

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

Regards

RoSchmi

Yes, you are right. I couldn't get HTTP GET/POST working with customized headers. The module seemded to add 'its own' headers. With sockets I got it working.

Regards

Roland