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: 16
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: 246
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: 16
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

August 25, 2018
10:23 am
Avatar
eplantes

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

Hello. Comming back to this topic...

I have been doing several tests using "https://api.thingspeak.com" as name server and "443" as port, but when I get connected to the server, the connection is closed in a few seconds. I haven't see any code example in the documentation that explains how to get this.

- Could someone give an example using secure protocol "https" and bulk update feature?
- Is it necessary use a certificate in the autenticantion step or something like that?
- Someone has experienced the same problems ?

Thanks

August 29, 2018
6:16 am
Avatar
eplantes

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

Hello again.

Mmmmm I found where was the error. I defined the port variable as a byte, not as an int. For this reason the output debugged showed 187 as port and not 443.
On another hand is not necessary defining the name server using the full path "https://api.thingspeak.com", we can use the settings as follows:

server: api.thingspeak.com
port: 443

I have done several tests using the bulk_update feature and this works fine!! : )

I'm very sorry for this stupid error.

Thanks

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
33 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

Janetkab, petersevruk, SGDamiano1, seanoz60, Beverlytreta, MartaKah

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457