Error Code Inconsistencies discovered when using Python Requests module: Status 200 returned when api request times out

Hey Spark Community,
I was recently using [Python’s requests module][1] to send data to my Spark Core and came upon inconsistencies in the response messages returned.

On sending a string that was too long, the request timed out and did not run on the Spark Core, but returned response code 200 as sketched out below:

string to be sent: "Rolene Strauss | Liverpool 4-0 Tottenham | Zipho | Lali EL ORGULLO ARGENTINO Esposito | Kim & Kanye | Vamos Werner | Unbeaten in 2014 | 1st Princess | Matlala | Coutinho 55" Result: Response [200] { "ok": false, "error": "Timed out." }

A similar result was received when I used curl except no error code was explicitly reported. Is this an error in the Cloud software?

There’s definitely an inconsistency between failures in communicating with the api and failures in communicating with devices.

Ex. Bad api keys act nothing like device timeouts or invalid variable names.

While I’m sure there’s reason for this, it would be nice for those to be consistent. Http error codes would be my preference.
For now you can draw that line at api error vs. device error.

I had to build my .NET wrapper to be aware of this difference then hide that difference from it’s client interface. I don’t like two different ways of doing the same thing in APIs.

1 Like