HTTPS Request from Spark Core?

I see! Thanks for the help. I’m trying to use this example to get something off of another website now, and although it connects, it says “Bad Request.” What could that mean? Do you think there is something wrong with my code, or something with the internet connection?

my Code:

char server[] = “”;
TCPClient client;

void setup() {
// Open serial communications and wait for port to open:

while(!Serial.available()) SPARK_WLAN_Loop();

if (client.connect(server, 80)) {
// Make a HTTP request:
client.println(“GET /api/v1/prices/spot_rate HTTP/1.0”);
client.println(“Content-Length: 0”);


void loop()

if (client.available()) {
char c =;

if (!client.connected())


The Spark Core cannot make a HTTPS connection. You’ll have to use a Proxy service for this, such as a PHP script running on a your webhost to forward the HTTP request for you to HTTPS, or wait for Spark Webhooks which will allow you to do the same thing :wink:


hmmm :frowning:okay. Do you think a beginner like me can do this, or it is really difficult? I have no clue where to even start! Thanks for all the help!

It’s not that difficult… you CAN learn :smile:

Basically you are trying to load this webpage to retrieve the Bit Coin spot price.

While we could work through how to do that, I don’t think it’s the FIRST thing I would attempt to do. FIRST thing I would do is go look for an Bitcoin Price Index that’s not SSL encrypted… however, this is a bit risky if you are trying to buy and sell real-time with that data. If you are just making a simple [WOW and FLUTTER meter ¹][1] for BITCOIN prices… this will do just fine though… here’s one:

¹ not the best analogy but hey you probably learned something new…

:blush:I did learn something new with that analogy! hehe! And I am just doing it for the WOW and FLUTTER meter!

So instead of:

I can use char server[] = “http://api/”;

and for

I can use client.println(“GET /v1/bpi/currentprice/USD.json”);

This should do it?

server, yes… path mostly correct… GET /v1/bpi/currentprice/USD.json HTTP/1.0 let me see if I can put together a full example for you… I’m trying out some new things I haven’t had a chance to play with yet, and it’s proving to be fun… yet challenging.

Hi @hassaan22

You don’t need the “http://” part, just the “” as the server name.

Then later on in the GET request line, you just need part after the server name as you have above.

1 Like

@hassaan22 here’s a good kick start for you :smile:

If you have any questions, please ask over there…


This is awesome! Thanks for the example @BDub

I was just working on JSON parsing with the with my Spark Core - glad to see a full working example to help me when I run into hiccups.