Java Library for Spark Cloud API?

I have looked around online for a Java Library for interfacing with the Spark Cloud API, but I have not found anything yet. Has anyone written an opensource Java controller for the Spark Cloud API?

I know people must be controlling their Cores with Java, so I guess everyone is just writing their own controllers?

Cloud API is a RESTful api, so any of the java technologies for talking to a REST endpoint should work for you.

If someone doesn’t post an existing java interface to the cloud API in this thread for you to use, it would be great to see what you produce!

I guess I will build one and put it on github. If anyone has time for a code review, let me know and I will message you when I have something review worthy.

Why not use SparkJS?

I wrote the beginning of one:

So far it supports calling functions and reading variables.

But I need some help. I can’t get it to delete a token. I can delete tokens using curl, but not with my HTTP client. (I am using http://unirest.io/java.html)

Here is my Unirest request:

HttpRequestWithBody req = Unirest.delete(baseUrl + "/v1/access_tokens/" + token.getKey())
            .header("accept", "application/json")
            .basicAuth(username, password);

Source code here, look at the deleteToken() function

I believe the issue is to do with how Unirest creates a DELETE request. It creates DELETE requests with a body. But the example curl command for deleting a token creates a GET request (without a body).

Here is the example curl:

curl https://api.spark.io/v1/access_tokens/b5b901e8760164e134199bc2c3dd1d228acf2d98 -u joe@example.com:SuperSecret -X DELETE

The -X flag just changes the actual word used in the request. It does not change the structure of the request.