Unable to POST to Things speak channel using TELIT LE910 Modem

2 views (last 30 days)
I want to POST to thingspeak channel using Telit LE910 modem. Able to successfully execute GET command to the same channel. From browser able to successfully POST data.
Tried following combination for posting data in both online mode and command mode, getting 400 Bad Request as response:
Online mode:
01/01/20 11:31:31>>>: AT#SSLD= 1,443,"api.thingspeak.com",0,0
01/01/20 11:31:33<<<:
01/01/20 11:31:33<<<: CONNECT
01/01/20 11:31:45>>>: POST /update HTTP/1.1<CR><LF>Host: api.thingspeak.com<CR><LF>Connection: close<CR><LF>X-THINGSPEAKAPIKEY: XXXXXXXXXXXXXXXX<CR><LF>Content-Type: application/x-www-form-urlencoded<CR><LF>Content-Length: 144<CR><LF><CR><LF>field1=111&field2=111111111111::11:11:11:11:11:11::O &field3=1111&field4=111111111111::111.1::11::XXXX XXX &field5=02.111111,11.111111&field6=11
01/01/20 11:31:51<<<: HTTP/1.1 400 Bad Request
01/01/20 11:31:51<<<: Server: awselb/2.0
01/01/20 11:31:51<<<: Date: Wed, 01 Jan 2020 06:01:50 GMT
01/01/20 11:31:51<<<: Content-Type: text/html
01/01/20 11:31:51<<<: Content-Length: 138
01/01/20 11:31:51<<<: Connection: close
01/01/20 11:31:51<<<:
01/01/20 11:31:51<<<: <html>
01/01/20 11:31:51<<<: <head><title>400 Bad Request</title></head>
01/01/20 11:31:51<<<: <body bgcolor="white">
01/01/20 11:31:51<<<: <center><h1>400 Bad Request</h1></center>
01/01/20 11:31:51<<<: </body>
01/01/20 11:31:51<<<: </html>
01/01/20 11:31:52<<<:
01/01/20 11:31:52<<<: NO CARRIER:SSL,1
Following is working response for GET command:
01/01/20 11:29:25>>>: AT#SSLD= 1,443,"api.thingspeak.com",0,0
01/01/20 11:29:26<<<:
01/01/20 11:29:26<<<: CONNECT
01/01/20 11:29:50>>>: GET /update?api_key=XXXXXXXXXXXXXXXX HTTP/1.1
Host: apithingspeak.com
01/01/20 11:29:56<<<: HTTP/1.1 200 OK
01/01/20 11:29:56<<<: Date: Wed, 01 Jan 2020 05:59:56 GMT
01/01/20 11:29:56<<<: Content-Type: text/plain; charset=utf-8
01/01/20 11:29:56<<<: Content-Length: 4
01/01/20 11:29:56<<<: Connection: keep-alive
01/01/20 11:29:56<<<: Status: 200 OK
01/01/20 11:29:56<<<: X-Frame-Options: SAMEORIGIN
01/01/20 11:29:56<<<: Access-Control-Allow-Origin: *
01/01/20 11:29:56<<<: Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH
01/01/20 11:29:56<<<: Access-Control-Allow-Headers: origin, content-type, X-Requested-With
01/01/20 11:29:56<<<: Access-Control-Max-Age: 1800
01/01/20 11:29:56<<<: ETag: W/"545fae2efd81862725c43a539e2936f3"
01/01/20 11:29:56<<<: Cache-Control: max-age=0, private, must-revalidate
01/01/20 11:29:56<<<: X-Request-Id: ef5ce9f0-8c7a-4aea-b718-8baf8e1e24d9
01/01/20 11:29:56<<<: X-Runtime: 0.035532
01/01/20 11:29:56<<<: X-Powered-By: Phusion Passenger 4.0.57
01/01/20 11:29:56<<<: Server: nginx/1.9.3 + Phusion Passenger 4.0.57
01/01/20 11:29:56<<<:
01/01/20 11:30:08>>>: 4184
Command mode:
01/01/20 11:47:12>>>: AT#SSLD= 1,443,"api.thingspeak.com",0,1
01/01/20 11:47:14<<<:
01/01/20 11:47:14<<<: OK
01/01/20 11:47:27<<<: AT#SSLSEND=1
01/01/20 11:47:44>>>: GET /update?api_key=XXXXXXXXXXXXXXXX HTTP/1.1
Host: apithingspeak.com
01/01/20 11:47:44<<<:
01/01/20 11:47:44<<<:
01/01/20 11:47:44<<<:
01/01/20 11:47:45<<<:
01/01/20 11:47:45<<<: OK
01/01/20 11:47:45<<<:
01/01/20 11:47:45<<<: SSLSRING: 1,648,HTTP/1.1 200 OK
01/01/20 11:47:45<<<: Date: Wed, 01 Jan 2020 06:17:45 GMT
01/01/20 11:47:45<<<: Content-Type: text/plain; charset=utf-8
01/01/20 11:47:45<<<: Content-Length: 4
01/01/20 11:47:45<<<: Connection: keep-alive
01/01/20 11:47:45<<<: Status: 200 OK
01/01/20 11:47:45<<<: X-Frame-Options: SAMEORIGIN
01/01/20 11:47:45<<<: Access-Control-Allow-Origin: *
01/01/20 11:47:45<<<: Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH
01/01/20 11:47:45<<<: Access-Control-Allow-Headers: origin, content-type, X-Requested-With
01/01/20 11:47:45<<<: Access-Control-Max-Age: 1800
01/01/20 11:47:45<<<: ETag: W/"2e311bdd3398de229dfc25107ce4c394"
01/01/20 11:47:45<<<: Cache-Control: max-age=0, private, must-revalidate
01/01/20 11:47:45<<<: X-Request-Id: 5bf33cc9-5df0-4f96-87ac-4a483836566d
01/01/20 11:47:45<<<: X-Runtime: 0.094855
01/01/20 11:47:45<<<: X-Powered-By: Phusion Passenger 4.0.57
01/01/20 11:47:45<<<: Server: nginx/1.9.3 + Phusion Passenger 4.0.57
01/01/20 11:47:45<<<:
01/01/20 11:47:45<<<: 4185
01/01/20 11:48:12<<<: AT#SSLSEND=1
01/01/20 11:48:40>>>: POST /update HTTP/1.1<CR><LF>Host: api.thingspeak.com<CR><LF>Connection: close<CR><LF>X-THINGSPEAKAPIKEY: XXXXXXXXXXXXXXXX<CR><LF>Content-Type: application/x-www-form-urlencoded<CR><LF>Content-Length: 144<CR><LF><CR><LF>field1=111&field2=111111111111::11:11:11:11:11:11::O &field3=1111&field4=111111111111::111.1::11::XXXX XXX &field5=02.111111,11.111111&field6=11
01/01/20 11:48:40<<<:
01/01/20 11:48:40<<<: OK
01/01/20 11:48:41<<<:
01/01/20 11:48:41<<<: SSLSRING: 1,288,HTTP/1.1 400 Bad Request
01/01/20 11:48:41<<<: Server: awselb/2.0
01/01/20 11:48:41<<<: Date: Wed, 01 Jan 2020 06:18:41 GMT
01/01/20 11:48:41<<<: Content-Type: text/html
01/01/20 11:48:41<<<: Content-Length: 138
01/01/20 11:48:41<<<: Connection: close
01/01/20 11:48:41<<<:
01/01/20 11:48:41<<<: <html>
01/01/20 11:48:41<<<: <head><title>400 Bad Request</title></head>
01/01/20 11:48:41<<<: <body bgcolor="white">
01/01/20 11:48:41<<<: <center><h1>400 Bad Request</h1></center>
01/01/20 11:48:41<<<: </body>
01/01/20 11:48:41<<<: </html>
01/01/20 11:48:41<<<:
01/01/20 11:50:11<<<:
01/01/20 11:50:11<<<: NO CARRIER:SSL,1
Kindly Guide how to post data
  2 Comments
Vinod
Vinod on 5 Jan 2020
Your request seems to have spaces(' ') in the request. This needs to be URL Encoded. So, a space (' ') needs to become %32.
Based on what is shared, this is not a correctly encoded HTTP request and I'd recommend using POSTMAN to first get the request correct before embedding it in your device.See the "Use POSTMAN to Wite Data with POST" example.
Rani H
Rani H on 6 Jan 2020
Thanks for your suggestion.I had tried Posting data using 'POST HTTP Requests Online', which worked. Same thing i posted to Telit modem. I will try POSTMAN.

Sign in to comment.

Answers (0)

Communities

More Answers in the  ThingSpeak Community

Categories

Find more on Read Data from Channel in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!