Testing bulk update feature using secure protocol HTTS | ThingSpeak API | Forum

Avatar

Please consider registering
Guest

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Testing bulk update feature using secure protocol HTTS
No permission to create posts
August 7, 2018
12:52 pm
Avatar
eplantes

Silver
Members
Forum Posts: 14
Member Since:
April 12, 2018
sp_UserOfflineSmall Offline

Hello.

After testing the bulk update feature using Arduino MKR GSM 1400 devices, is time to improve my system. In fact, I would like to know how to post my requests across HTTP using SSL, I mean using HTTPS. This protocol is very important if I want to avoid the data can be intercepted by others.

My program is based on the example explained on this page "Bulk-Update a ThingSpeak Channel Using an Arduino MKR1000 Board or an ESP8266 Board", so I'm sending data across the network in plain text.

I have been doing several tests applying this changes:
- The port "from 80 to 443",
- Using the same server name "api.thingspeak.com".
- Changing GSMClient to GSMSSLClient

But when I try to connect to the server this fails. Maybe the url is incorrect with 443 port. Finally, my code is very similar to this:

.....

//Define the ThingSpeak server.
char server[] = "api.thingspeak.com"; // ThingSpeak Server

......
if (client.connect(server, 443)) {
client.println("POST /channels/YOUR-CHANNEL-ID/bulk_update.json HTTP/1.1"); // Replace YOUR-CHANNEL-ID with your ThingSpeak channel ID
client.println("Host: api.thingspeak.com");
client.println("User-Agent: mw.doc.bulk-update (Arduino ESP8266)");
client.println("Connection: close");
client.println("Content-Type: application/json");
client.println("Content-Length: "+data_length);
client.println();
client.println(data);
......
}
......

Could someone explain me how do get this??

thanks

August 10, 2018
2:13 pm
Avatar
Vinod

MathWorks
Members
Forum Posts: 223
Member Since:
May 1, 2016
sp_UserOfflineSmall Offline

Port 443 is correct, however you want to change your server to https://api.thingspeak.com (note the extra S in the URL)

August 14, 2018
6:55 am
Avatar
eplantes

Silver
Members
Forum Posts: 14
Member Since:
April 12, 2018
sp_UserOfflineSmall Offline

Thanks Vimod.

I use 443 as port and " https://api.thingspeak.com" as name server. I can connect to the server using this settings, but after to write in the socket "method client.print()..", for some strange reason the connection is closed and the channel is not updated. Maybe this connection is closed by the server but I'm very sure. On another hand I use the same parameters and headers commented in last post.

POST /channels/MY_CHANNEL/bulk_update.json HTTP/1.1
Host: api.thingspeak.com
Content-Type: application/json
Content-length: 231 or something like that
Connection: close

Thank you very much

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
32 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 261

Vinod: 196

piajola: 85

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

Newest Members:

Georgesic, BalladolbineAboth, Wayneamure, MattonAboth, ginatm2, Spreeuw

Administrators: Hans: 387, lee: 457