Can't get HTTP Post to work

  • Hi,


    I am having issues trying to get HTTP/POST to work via the Python script. I am executing the following commands:


    AT+CGDCONT=1,"ip","internet"

    AT#SGACT=1,1

    AT#SSLEN=1,1

    AT#SSLCFG=1,1,300,90,100,50,0,0,0,0

    AT#SSLSECCFG=1,0,0

    AT#SSLD=1,443,"www.xyz.com",0,0// This returns CONNECT

    Then using MDM.Send(senddata,10)

    where senddata contains:


    "POST /test0/post.php?mode=save&key=somekey&imei=someimei HTTP/1.1

    Host: www.xyx.com

    Content-Length: 45


    data=29/03/2019T15:42:00Z;22.20;1023.88;0.00;

    "

    When I read the response via MDM.Read I get NO CARRIER


    Would appreciate any advice on where I might be going wrong,

    Many thanks

  • Hi,


    Each line of the http header should be terminated with \r\n

    senddata = "POST /test0/post.php?mode=save&key=somekey&imei=someimei HTTP/1.1\r\n"

    senddata = senddata + "Host: www.xyx.com\r\n"

    senddata = senddata + "Content-Length: 45\r\n"

    senddata = senddata + "\r\n"

    senddata = senddata + "data=29/03/2019T15:42:00Z;22.20;1023.88;0.00;"

    Also it might be that the customer might need to do this:

    senddata = "POST /test0/post.php HTTP/1.1\r\n"

    senddata = senddata + "Host: www.xyx.com\r\n"

    senddata = senddata + "Content-Length: 81\r\n"

    senddata = senddata + "\r\n"

    senddata = senddata + "mode=save&key=somekey&imei=someimei&data=29/03/2019T15:42:00Z;22.20;1023.88;0.00;"

    This depends on the web server if it can interpret the HTTP headers in the first case.

    I would also recommend testing the HTTP headers using a TCP terminal like Hercules.