-->
Page 1 of 2

Cant send that simple post request .despaired !

PostPosted: Thu Jan 29, 2015 3:42 am
by rant
I have some post request in which i would like to send with the module, and get a JSON respond .
The request DOES works with any pc browser, but on the module i get "wrong syntax" when sent .

The request(which you can check on any browser) is this :
Code: Select allhttps://y4eI4XmKNT5D6MVtC565xkEjBAkggTlTMt1erNKv:javascript-key=NOkyJ0XBB4gdANXSCGE0slnH0QKXhZ5OPf7ma4Gk@api.parse.com/1/classes/DATA/TXcgRDCCRR


than the GET request is this :

Code: Select all    cmd="GET / HTTP/1.0\r\n HOST: https://y4eI4XmKNT5D6MVtC565xkEjBAkggTlTMt1erNKv:javascript-key=NOkyJ0XBB4gdANXSCGE0slnH0QKXhZ5OPf7ma4Gk@api.parse.com/1/classes/DATA/TXcgRDCCRR\r\n\r\n";


which looks like this :
Code: Select allAT+CIPSTART=4,"TCP","api.parse.com",443
AT+CIPSEND=4,171
GET / HTTP/1.0
 HOST: https://y4eI4XmKNT5D6MVtC565xkEjBAkggTlTMt1erNKv:javascript-key=NOkyJ0XBB4gdANXSCGE0slnH0QKXhZ5OPf7ma4Gk@api.parse.com/1/classes/DATA/TXcgRDCCRR



I have tried many configurations(with/without the HTTP etc), so please advice me on something you can check and get a JSON respond .

Thanks a lot !

Re: Cant send that simple post request .despaired !

PostPosted: Thu Jan 29, 2015 4:41 am
by Sprite_tm
Ah, there's so much wrong there...

First of all, you can't just connect to a https service by just modifying the port to 443. You need to set up a SSL connection. Unfortunately, I have no idea if the AT firmware can do that.
Secondly, your URL consists of 3 parts, which a browser will happily split and handle separately before it gets sent over the line:

y4eI4XmKNT5D6MVtC565xkEjBAkggTlTMt1erNKv:javascript-key=NOkyJ0XBB4gdANXSCGE0slnH0QKXhZ5OPf7ma4Gk
These are actually an username and password separated by a colon

api.parse.com
This is the hostname

/1/classes/DATA/TXcgRDCCRR
This is the path.

Handling the username/password bit actually is somewhat complicated, but without it, your GET request should look like this:
GET /1/classes/DATA/TXcgRDCCRR HTTP/1.0
Host: api.parse.com
You will need to look up how to do authentication yourself. Hint:L Google for 'http basic authentication'

Re: Cant send that simple post request .despaired !

PostPosted: Thu Jan 29, 2015 5:03 am
by rant
Thanks a lot .

First of all , i actually can connect to the server using the port 443 , the connection is ok .
Second, i guess i will need http basic authentication , but the main goal here is to send push notification to a user's iPhone ,
I chose Parse server API , but i guess that any other service that do that(pushes), will require authentication , isn't it ?

So , how do you suggest us to send pushes in a simple way using the module ? ( Thingspeak ? IFTTT ? )

Thanks .

Re: Cant send that simple post request .despaired !

PostPosted: Thu Jan 29, 2015 5:21 am
by rant
Another thing , i found their REST API page, which say how you should construct the request ,
http://blog.parse.com/2012/01/19/javasc ... -rest-api/

I guess i just have to build a header from this ?