Trying to do spark.publish

Ok, so I have a question regarding publishing data with the spark core. I followed this tutorial here: Tutorial: Getting Started with Spark.publish()

I did everything and I was able to get my spark core to publish data through the api.spark.io web site. What I want to do now is publish this data to my company’s web site. My company has already set up a site that you can connect your spark core to and also should be able to publish with api. I do want to keep the company anonymous, so Lets just say the web site is called mywebsite.com. The company has set up api.mywebsite.com which should allow you to publish data through. So I tried using the html code from that web site except I changed the part of the code that says:

var eventSource = new EventSource("https://api.spark.io/v1/devices/" + deviceID + "/events/?access_token=" + accessToken);

I changed it to:

var eventSource = new EventSource("https://api.mywebsite.com/v1/devices/" + deviceID + "/events/?access_token=" + accessToken);

and when I run it it only gives me the first screen but when I click connect, it just says that it is waiting to receive data and it never actually gets anything I guess. Could someone please tell me why it won’t receive the data? and yes before someone asks I do have the access token linked to my company’s web site and everything. All the help is appreciated!

The url you changed is the API endpoint from :spark: that created so you need to check with your company if that’s the same format and the /events/?.... etc etc etc

Hi @SlinkyMation

It sounds like your company has a private cloud from Particle so you should make sure you don’t need to change the keys on the Core or let your company know that this Core should pair with the private cloud.

The public key for every Particle product is recorded while the parts in the factory and the public key for the Particle cloud is set in the Core, so they can talk to each other. For a private cloud, these keys can be different.

Best to ask someone in your company.

1 Like