Incorrect HTTP response code

Hi, I’m using the Spark API to do some communications from a server to the core. According to the documentation I should be seeing standard HTTP codes. However, there seems to be some inaccuracy. For example, if I unplug the core, and make the call, I still get a 200 response, even though it seems like I should get a 404 or 408 error. When the core is unplugged, I do get as part of the response data: { ok: false, error: 'Timed out.' }, so I can filter based on that, but that ignores the issue of incorrect error codes. Am I just misreading something?

Hi @cmn_jcs, it’s possible that our error codes are not correct in some cases. Would you mind posting the complete interaction you’re having with the API, including your complete API call (with your access token obscured) and the complete response?

Just want to quickly pop by to say that the cloud has some kind of delay in terms becoming aware of the core timeout when it is unplugged.

That’s the same behavior on the local :cloud: as well…

If the server sends back anything should be a 200, as the server is giving a response. that’s part of the HTML standard.

it wont matter if the core is online or offline, if the server responds it should be 200 OK. a 404 would indicate that the page you are trying to reach was not found on the server, indicating a fault on the server (incorrect request most likely) or a 500 error meaning that the page you requested has failed to run properly… normally a coding error

the response you get is probably more useful anyway, its saying you reached the spark server, it understood what you wanted but it couldn’t connect to the core within the time period required

Thanks for the thoughts all.

@zach: call from the server is:


{ statusCode: 200,
   content: '{\n  "ok": false,\n  "error": "Timed out."\n}',
    { server: 'nginx/1.6.0',
      date: 'Tue, 14 Oct 2014 14:51:21 GMT',
      'content-type': 'application/json; charset=utf-8',
      'content-length': '42',
      connection: 'keep-alive',
      'x-powered-by': 'Express',
      'access-control-allow-origin': '*' },
   data: { ok: false, error: 'Timed out.' } }

I get why there could be a 200 code–the Spark cloud is technically returning normally. But the documentation specifically says 200 is “OK - API call successfully delivered to the Core and executed.”, while 404 is “404 Not Found - The Core you requested is not currently connected to the cloud.” Perhaps this is related to what @kennethlimcp stated about the delay between disconnect and the cloud recognizing that?

@kennethlimcp: Thanks–any idea on what the normal timeout is?

@Hootie81: but the documentation explicitly says otherwise; see my response to @zach.