# HTTPS Request from Spark Core?

**URL:** <https://community.particle.io/t/https-request-from-spark-core/5376>\
**Category:** Cloud\
**Created:** [June 26, 2014, 8:48pm UTC](https://community.particle.io/t/https-request-from-spark-core/5376 "2014-06-26T20:48:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hassaan22](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hassaan22/32/2865_2.png) [@hassaan22](https://community.particle.io/u/hassaan22)\
**Post date:** [June 26, 2014, 7:28pm UTC](https://community.particle.io/t/https-request-from-spark-core/5376/1 "2014-06-26T19:28:47Z")

</div>

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[] = “[https://coinbase.com](https://coinbase.com)”;  
TCPClient client;

void setup() {  
// Open serial communications and wait for port to open:  
Serial.begin(9600);

while(!Serial.available()) SPARK\_WLAN\_Loop();

if (client.connect(server, 80)) {  
Serial.println(“connected”);  
// Make a HTTP request:  
client.println(“GET /api/v1/prices/spot\_rate HTTP/1.0”);  
client.println(“Host: [https://coinbase.com/](https://coinbase.com/)”);  
client.println(“Content-Length: 0”);  
client.println();  
}

}

void loop()  
{

if (client.available()) {  
char c = client.read();  
Serial.print©;  
}

if (!client.connected())  
{  
Serial.println();  
Serial.println(“disconnecting.”);  
client.stop();  
delay(5000);  
}  
}

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [June 26, 2014, 7:35pm UTC](https://community.particle.io/t/https-request-from-spark-core/5376/2 "2014-06-26T19:35:43Z")

</div>

`client.println("Host: https://coinbase.com/");`

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 😉

---

<div class="post-metadata">

**Author:** ![hassaan22](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hassaan22/32/2865_2.png) [@hassaan22](https://community.particle.io/u/hassaan22)\
**Post date:** [June 26, 2014, 8:34pm UTC](https://community.particle.io/t/https-request-from-spark-core/5376/3 "2014-06-26T20:34:40Z")

</div>

hmmm ☹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!

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [June 26, 2014, 9:01pm UTC](https://community.particle.io/t/https-request-from-spark-core/5376/4 "2014-06-26T21:01:33Z")

</div>

It’s not that difficult… you CAN learn 😄

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

[https://coinbase.com/api/v1/prices/spot\_rate](https://coinbase.com/api/v1/prices/spot_rate)

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:

[http://api.coindesk.com/v1/bpi/currentprice/USD.json](http://api.coindesk.com/v1/bpi/currentprice/USD.json)

* * *

¹ not the best analogy but hey you probably learned something new…  
[1]: [http://en.wikipedia.org/wiki/Wow\_and\_flutter\_measurement](http://en.wikipedia.org/wiki/Wow_and_flutter_measurement)

---

<div class="post-metadata">

**Author:** ![hassaan22](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/hassaan22/32/2865_2.png) [@hassaan22](https://community.particle.io/u/hassaan22)\
**Post date:** [June 26, 2014, 9:40pm UTC](https://community.particle.io/t/https-request-from-spark-core/5376/5 "2014-06-26T21:40:58Z")

</div>

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

So instead of:

> [@hassaan22](#):
>
> char server = "[https://coinbase.com](https://coinbase.com)";

I can use char server = "[http://api/coindesk.com](http://api/coindesk.com)";

and for

> [@hassaan22](#):
>
> client.println("GET /api/v1/prices/spot\_rate HTTP/1.0");

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

This should do it?

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [June 27, 2014, 1:19am UTC](https://community.particle.io/t/https-request-from-spark-core/5376/6 "2014-06-27T01:19:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bko](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bko/32/20704_2.png) [@bko](https://community.particle.io/u/bko)\
**Post date:** [June 27, 2014, 1:40am UTC](https://community.particle.io/t/https-request-from-spark-core/5376/7 "2014-06-27T01:40:04Z")

</div>

Hi @hassaan22

You don’t need the “http://” part, just the “[api.coindesk.com](http://api.coindesk.com)” as the server name.

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

---

<div class="post-metadata">

**Author:** ![BDub](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/bdub/32/5137_2.png) [@BDub](https://community.particle.io/u/BDub)\
**Post date:** [June 27, 2014, 5:27am UTC](https://community.particle.io/t/https-request-from-spark-core/5376/8 "2014-06-27T05:27:29Z")

</div>

@hassaan22 here’s a good kick start for you 😄

> **[Bitcoin Price Index JSON Parse TCP Client](https://community.particle.io/t/bitcoin-price-index-json-parse-tcp-client/5383)**
>
> Here’s a full example of a Bitcoin Price Index JSON parsing TCP Client. The end result is the BPI value as a Double precision variable that you can work with. Remember you have to open a serial terminal after you boot your Core, then press ENTER. ...

If you have any questions, please ask over there…

---

<div class="post-metadata">

**Author:** ![gerv](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/gerv/32/20741_2.png) [@gerv](https://community.particle.io/u/gerv)\
**Post date:** [June 27, 2014, 9:16pm UTC](https://community.particle.io/t/https-request-from-spark-core/5376/9 "2014-06-27T21:16:24Z")

</div>

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.
