cancel
Showing results for 
Search instead for 
Did you mean: 

HTTPPOST Example Android GCM

florian239955_st
Associate II
Posted on March 23, 2015 at 13:57

Hi All,

I'm evaluating the SPWF01, so I want to send an Android GCM HTTP post (json or plain text) - but I've no success.

I tried it with:

AT+S.HTTPPOST=android.googleapis.com,/gcm/send,Content-Type:application/x-www-form-urlencoded;charset=UTF-8&Authorization:key=APIKEY,80

and also with:

AT+S.HTTPPOST=android.googleapis.com,/gcm/send,Content-Type:application/json&Authorization:key=APIKEY,80

I got following answer:

HTTP/1.0 401 Unauthorized

Has anybody an idea or can give me an example how to send the http header via the SPWF AT command?

Best regards,

Flo

#http-post #spwf #gcm
20 REPLIES 20
florian239955_st
Associate II
Posted on November 09, 2015 at 17:24

Hi Gergely,

no, I'm still waiting for an update and didn't spend more time in solving this.

Meanwhile, I regret choosing the ST module. The firmware seems to be still in development...

With the microchip RN171 module I send the GCM request without problems. Maybe I will go back to that module...

Regards,

Flow

Posted on November 09, 2015 at 18:20

Flow,

when the FW is closed, the product is dead.

- If you report  a bug, it will be solved

- If you want a new feature, it will be discussed, and hopefully implemented/tested/released.

You opened a new feature request in March, when FW3.3 was under testing (and, so, new features could not be added).

FW3.4 is currently under testing, with the new feature you asked for.

If you think other modules will implemet your requests, or if you get the same support from other module makers, it's really good for you.

Regards

jerry

florian239955_st
Associate II
Posted on November 10, 2015 at 09:48

Dear Jerry,

That’s a little bit off-topic, but let me answer to your post.

when the FW is closed, the product is dead.

 

- If you report  a bug, it will be solved

 

- If you want a new feature, it will be discussed, and hopefully implemented/tested/released.

Bug fixes are always necessary. That’s not the problem. I didn’t request a new feature. I just want to use the http post command. Your customers want to have a product, that has the described features.  I just want to update my application and I don’t want to care about updating the wlan module in my application to reduce testing costs. I hope you understand this.

You opened a new feature request in March, when FW3.3 was under testing (and, so, new features could not be added).

As I described, I didn’t asked for a new feature. The feature httppost is described in the wifi hands on tutorial. But I (and Anton and Gerkely) didn’t get this working with the GCM server.

FW3.4 is currently under testing, with the new feature you asked for.

FW3.4 is an official version and shouldn’t a testing version, isn’t it? And I still don’t get it working (like Anton, Gerkely)…

Hi Sergey,

 

 

using current FW release, the only possibility is to open a socket and manage custom http request by SOCKW command.

 

Next FW release will allow to solve this current limit. Stay tuned :)

 

 

j

The next FW release you are talking about is FW3.5? So I’m confused, if it is in FW3.4 or not.

If you think other modules will implemet your requests, or if you get the same support from other module makers, it's really good for you.

Dear Jerry, you are doing here a great job and I like your fast response time on any topics here. But…

The other module already had this feature. So, I didn’t request a new feature. I switched to the ST module, because of the ssl feature, that would be added to the other module in a later update. I don’t want to add features of the wlan module via update. That’s why I chose your module. And know I have the same trouble with updating the module. This should only be necessary if there are big bugs to be fixed. And after half a year I still wait to use that function. I’m sure you will understand that I’m not happy at all. But I’m still looking forward to fix this…

Best regards,

Flow

Posted on November 10, 2015 at 09:56

3.4 and 3.5

not 3.3. and 3.4

my error

florian239955_st
Associate II
Posted on November 27, 2015 at 08:39

Hi Gerry,

no problem. Can you tell us, when the next firmware version will be released?

If I look on the number of views of this topic, a lot of people are interested in this feature / function. So you will make a some people happy... ;)

Cheers,

Flo

tom239955_st
Associate II
Posted on December 23, 2015 at 19:40

Hi,

I am also interested in knowing when the next release which supports ''application/json'' is going to be available.

Thanks,

Tom

florian239955_st
Associate II
Posted on March 29, 2016 at 17:10

Hi,

does anybody get the GCM with the SPWF working?

I can send the http post with the headers, but I get a ''http/1.0 400 bad response'' answer. Google says, this means a invalid json format:

Check that the JSON message is properly formatted and contains valid fields (for instance, making sure the right data type is passed in).

AT Command for SPWF:

AT+S.HTTPREQ=android.googleapis.com,80,388

Data to SPWF:

POST /gcm/send HTTPS/1.1

Content-Type: application/json

Authorization: key=AIzaSyDxxxxxxxxxxxxxxxxxxxxxxxxxxxvdw

Content-Length: 243

{''data'': {''Error1'': ''Test'' ''Error2'': '' erfolgreich'' },''registration_ids'' :  [''APA91xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxvxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxg7VK0nrXGH_X3etP2vij3_8K7kdJGPC5q_jQmUybtPUTzEnIVPUJ89fA'']}

I tested the json message with other tools and it works fine. So, any hints are appreciated :)

Regards,

Flow
florian239955_st
Associate II
Posted on April 07, 2016 at 07:31

hi,

here is my solution:

Command to module:

AT+S.HTTPREQ=android.googleapis.com,80,388

Header:

POST /gcm/send HTTP/1.1

Host: android.googleapis.com:80

Content-Type: application/json

Content-Length: 243

Authorization: key=AIzaSxxxxxxxxxxxxxxxxxxxxx

JSON:

data'': {''Error1'': ''Test'' ''Error2'': '' erfolgreich'' },''registration_ids'' :  [''APA91bxxxxxxxxxx'']}

- between header and JSON: \r\n\r\n

- after JSON  \r\n\r\n

- HTTPS doesn't work

Cheers,

Flow
Posted on April 07, 2016 at 08:22

Hi Flow,

HTTPS client is not part of SPWF01S product. If you need an HTTPS request, open a socket on webserver port 443.

Best regards

j

tgai9
Associate II
Posted on June 16, 2016 at 15:12

Hi Flow and Jerry,

I can't yet succesfully send a POST with the httpreq command.

I don't understand how you, Flow, used the last \r\n after the json data (do you count or not in the data length for the httpreq?).

Actually evrey POST I send is received by the server with body null.

I' trying this:

POST /ceza/post.php HTTP/1.1

Host: elbuild.com

Content-Type: application/json

{''id'':2,''n'':''Tommaso''}

Actually the server should reply the echo of the body received (you can try yourself, with postman app for example). How did you format the httpreq command to have a non null body?

Best regards,

Tommaso