[SOLVED] : Spark Cloud - Error 401

Hello @Ricky here. I have had my Spark Core for a while and everything is great, but I have been going through the different tutorials on [Spark Docs][1] and know I got into [Cloud Code (API)][2] and I have been having some problems. I am now trying to post a value onto the Spark Cloud. The way to access your Spark Cloud is that you have to have your Access Token of your username, which can be accessed under the Spark Build Settings and the Device ID of your Spark Core.

The way of doing it is:
https://api.spark.io/v1/devices/*Your Device ID*/temperature%20/%20-d%20access_token=YOUR ACCESS TOKEN.

But recently since I started pasting this into the browser it has come up with this:

{
  "code": 400,
  "error": "invalid_request",
  "error_description": "The access token was not found"
}

I did a bit of research and found out that this is called a 401 unauthorized Error ([Spark Cloud][2]) or 401 Unauthorized - Your access token is not valid.

If you know anything about this then PLEASE reply to this topic.

Thanks,
@Ricky
[1]: http://docs.spark.io/
[2]: http://docs.spark.io/api/

For Spark.variable() you need a GET request to use the browser directly.

https://api.spark.io/v1/devices/DEVICE_ID_OR_NAME/temperature?access_token=ACCESS_TOKEN

For Spark.function() you need a POST request which needs special formatting, and a site like www.hurl.it can help ya!

Or you can use Spark Dev to access Spark variables and functions much more easily.

2 Likes

Thanks @BDub. It Worked.

1 Like