API.invoke raises error on non-200 response