cancel
Showing results for 
Search instead for 
Did you mean: 

SPMW01SA HTTP post with JSON format

reedomneck
Associate III
Posted on March 16, 2016 at 16:03

Hi All,

For my project i am using SPMW01SA WiFi module and still we are in development stage so we are doing our R&D on STEVAL-IDI004v2 evaluation board.

STEVAL-IDI004v2 board WiFi is able to connect to internet and when we are trying to send sensor data to cloud WiFi module is responding back with arguments are missing. 

Our cloud is expecting data in JSON format and HTTP post method.

Can anyone please help me on this.

Regards,

--Manz

#https://my.st.com/public/ste2eco
13 REPLIES 13
florian239955_st
Associate II
Posted on March 29, 2016 at 17:00

Hi J,

now, the page accepts the length information. I had to add HTTPS/1.1 in the first line:

POST /gcm/send HTTPS/1.1

Also I didn't tell, when the header ends. This is done by adding \r\n\r\n

Now I get a bad request answer, so something is still not working but I hope to solve this (this year ;-))

I will post some code in the GCM topic..

Thx & cheers,

Flow
Posted on March 30, 2016 at 10:39

Flow,

Minimal HTTP request MUSTinclude some required fields:

GET / HTTP/1.1

Host: www.example.com

Connection: close



HTTP version (1.1 here), and CrLfCrLf (2x) at the end, are mandatory. For your final step I suggest: - open a socket server on a PC (e.g.: nc -l 80) - use your tool to connect to this ''fake'' webserver You'll find on console how the request is formatted. Copy whole string inside HTTPREQ payload, and should be working. Bye j
florian239955_st
Associate II
Posted on April 07, 2016 at 07:25

Hi Gerry,

I get it... I had to add

Host: www.example.com

and use HTTP/1.1 instead of HTTPS/1.1 I will provide the example in the Android GCM thread. Thank you for your support. Regards, Flow
Posted on April 07, 2016 at 08:19

Hi Flow,

As far as I know, 

HTTPS/1.1 is wrong. Means nothing.

The HTTP request is totally independent of the TLS encryption.

Both HTTP and HTTPS begins with a TCP connection setup. When webserver receive a TCP connection request, it will request certificates to remote host. Then, after connection is created, ''strings'' are automatically encrypted/decrypted.

So, ''GET HTTP/1.1'' will be an HTTPS GET.

Minimal HTTP GET request MUST be well formatted

Hope it's clear.

Ciao

j