[API] fix exception triggered when API Response HTTP Code != 200

When calling the API through the SDK using AJAX, if the response HTTP response code is != 200 an error occurs.

Since the API may return response in various HTTP code (200, 401, ...) we should not focus only on "200" responses.