Community
cancel
Showing results for 
Search instead for 
Did you mean: 
MMarc34
Novice
1,474 Views

Call https REST API with Edison and Arduino sdk

How to call https rest api like "https://test0001.azure-devices.net/Devices/Edison/Messages/devicebound?API-Version=2016-02-03 https://test0001.azure-devices.net/Devices//Messages/devicebound?API-Version=2016-02-03"

with Edison and Arduino sdk?

When using WiFi.h libray I can call host https://test0001.azure-devices.net/Devices/Edison/Messages/devicebound?API-Version=2016-02-03 test0001.azure-devices.net on port 443 and send a "GET instruction" but cannot get any answer from service

On the other hand, when calling REST API on http (port 80) everything is fine.

Anybody can help on that?

Thanks

Regards

Marco

4 Replies
idata
Community Manager
44 Views

Hello marco1971,

 

 

Could you please check the links you posted? They don't work for me, could you please check them and post them again? Or could you please explain more deeply what you're trying to do.

 

 

-Peter.
MMarc34
Novice
44 Views

Dear Peter,

I'm trying to send and retrieve data with Azure Iot Hub.

I can manage REST calls with other application like FIddler (for instance), sending GET commands in this way

GET https://test0001.azure-devices.net/Devices/Edison/Messages/devicebound?API-Version=2016-02-03 HTTP/1.1

Authorization: SharedAccessSignature sr=TEST0001.azure-devices.net&sig=3ftOC5UzpYAH1oTJP9Ka6%2bNRlhK3CKg4ap/XETjDpC8%3d&se=1494001566&skn=iothubowner

Host: test0001.azure-devices.net

Content-Type: application/json

With Fiddler (and other applications) this works. Now I'm trying to do the same thing inside an Arduino sketch like this one (omit wifi connection commands and other):

...

const char *server = "test0001.azure-devices.net";

if (client.connect(server, 443)) {

client.println("GET /Devices/Edison/Messages/devicebound?API-Version=2016-02-03 HTTP/1.1");

client.println("Authorization: SharedAccessSignature sr=TEST0001.azure-devices.net&sig=3ftOC5UzpYAH1oTJP9Ka6%2bNRlhK3CKg4ap/XETjDpC8%3d&se=1494001566&skn=iothubowner");

client.println("Host: test0001.azure-devices.net");

client.println("Content-Type: application/json");

...

Result is: connection to host is done, but I get no answer. When I compose other skecth like the one above for connecting on http host (port 80) everything is fine

Could you indicate what is missing to make REST calls works with https ssl?

Thanks

Marco

MMarc34
Novice
44 Views

Thanks a lot Peter.

Just a question before I flash the board: could my Issue be related with what is described in http://forum.arduino.cc/index.php?topic=17540.0 http://forum.arduino.cc/index.php?topic=17540.0 ?

Symptoms described in this arduino forum discussion are exactly the same I am experiencing. The only difference is that I am using WiFi.h library for internet connection. It seems that WiFi101.h library for Arduino IDE admit ssl connection, but this library is not available for Edison

Thanks

Regards

Marco

idata
Community Manager
44 Views

That could indeed be affecting you. But if that was the case, I'd suggest you to change to programming on the Linux side. If you do it you'd have access to every third party Linux library, which could make things simpler when trying to interact with SSL connections.

 

 

For example you can look at this links:

 

 

http://stackoverflow.com/questions/7698488/turn-a-simple-socket-into-an-ssl-socket

 

http://fm4dd.com/openssl/sslconnect.htm

 

https://www.cs.utah.edu/~swalton/listings/articles/ssl_client.c

 

https://wiki.openssl.org/index.php/SSL/TLS_Client

 

http://www.cs.odu.edu/~cs772/fall08/lectures/ssl_programming.pdf

 

 

-Peter.
Reply