Google 云端点错误响应
Google cloud endpoints wrong response
我正在使用 Google 云端点,一切都很好。
但是当我将我的 Android 密钥和网络密钥更新为生产模式时,每个请求 returns
200 为空或 400 为空。
我重建了项目,但没有任何效果我正在尝试 Android 和 api 资源管理器以及 return :状态代码然后为空
尽管完整的结果包含在 JSON 格式的响应中。
我收到回复,但状态消息始终为 null
您可以在此 URL 尝试一下并查看结果:
https://apis-explorer.appspot.com/apis-explorer/?base=https%3A%2F%2Fcutter-1215.appspot.com%2F_ah%2Fapi#p/userRegistrationApi/v1/userRegistrationApi.signUser
更新:
经过一些实验后,由 Google chrome 或 android 设备编辑的状态消息 return 为 null ,但在 Firefox 上它不是 null 并且可以正常工作。
不知道是什么原因
最新的 chrome 版本对此有问题。希望在 chrome 的下一个版本或更新中尽快修复它。
即使我也面临着同样的问题。一个简单的解决方法是在其他浏览器中测试端点 (IE/Firefox/Safari).
希望对您有所帮助。
我发现问题是 Google Chrome 新算法可能它删除了一些 headers 以使其浏览器更快。
解决方案在 chrome 上,只是不要使用它并使用任何其他浏览器,它应该可以正常工作。
但是,在 Android 上,尤其是 Lollipop (5.0),它基于 Chromenum,它基于 Chrome ... 我遇到的问题与 google chrome 我遇到了 android 并且响应为空响应。
我已将 Google 云端点的用户代理更改为 Firefox,一切正常。
private static final String firexFox_userAgent = "Mozilla/5.0 (Windows NT 6.1; rv:40.0) Gecko/20100101 Firefox/40.0";
private static final HttpRequestInitializer intializer = new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) throws IOException {
final HttpHeaders headers = request.getHeaders();
List<String> agents = new ArrayList<>();
agents.add(firexFox_userAgent);
headers.put("User-Agent", agents);
}
};
并将其添加到 api 构建器
private static UserRegistrationApi mUserRegApi mUserRegBuilder = new UserRegistrationApi.Builder(EnpointConsts.sAndroidHttp, EnpointConsts.sGsonFactory, CredentialHolder.getCredential()).setApplicationName(Consts.APP_ID).setHttpRequestInitializer(intializer);
我正在使用 Google 云端点,一切都很好。 但是当我将我的 Android 密钥和网络密钥更新为生产模式时,每个请求 returns 200 为空或 400 为空。
我重建了项目,但没有任何效果我正在尝试 Android 和 api 资源管理器以及 return :状态代码然后为空 尽管完整的结果包含在 JSON 格式的响应中。 我收到回复,但状态消息始终为 null
您可以在此 URL 尝试一下并查看结果: https://apis-explorer.appspot.com/apis-explorer/?base=https%3A%2F%2Fcutter-1215.appspot.com%2F_ah%2Fapi#p/userRegistrationApi/v1/userRegistrationApi.signUser
更新: 经过一些实验后,由 Google chrome 或 android 设备编辑的状态消息 return 为 null ,但在 Firefox 上它不是 null 并且可以正常工作。 不知道是什么原因
最新的 chrome 版本对此有问题。希望在 chrome 的下一个版本或更新中尽快修复它。 即使我也面临着同样的问题。一个简单的解决方法是在其他浏览器中测试端点 (IE/Firefox/Safari).
希望对您有所帮助。
我发现问题是 Google Chrome 新算法可能它删除了一些 headers 以使其浏览器更快。 解决方案在 chrome 上,只是不要使用它并使用任何其他浏览器,它应该可以正常工作。 但是,在 Android 上,尤其是 Lollipop (5.0),它基于 Chromenum,它基于 Chrome ... 我遇到的问题与 google chrome 我遇到了 android 并且响应为空响应。 我已将 Google 云端点的用户代理更改为 Firefox,一切正常。
private static final String firexFox_userAgent = "Mozilla/5.0 (Windows NT 6.1; rv:40.0) Gecko/20100101 Firefox/40.0";
private static final HttpRequestInitializer intializer = new HttpRequestInitializer() {
@Override
public void initialize(HttpRequest request) throws IOException {
final HttpHeaders headers = request.getHeaders();
List<String> agents = new ArrayList<>();
agents.add(firexFox_userAgent);
headers.put("User-Agent", agents);
}
};
并将其添加到 api 构建器
private static UserRegistrationApi mUserRegApi mUserRegBuilder = new UserRegistrationApi.Builder(EnpointConsts.sAndroidHttp, EnpointConsts.sGsonFactory, CredentialHolder.getCredential()).setApplicationName(Consts.APP_ID).setHttpRequestInitializer(intializer);