0
votes

I was working with Google cloud endpoints and everything was fine. But when I updated my Android key and web key to production mode every request returns 200 null or 400 null.

I have rebuilt the project and nothing worked I am trying in both Android and api explorer and both return : status code then null Despite that the full result is contained in the response in JSON format . I get the response but the status message always null

You can try it at this URL and see the result : https://apis-explorer.appspot.com/apis-explorer/?base=https%3A%2F%2Fcutter-1215.appspot.com%2F_ah%2Fapi#p/userRegistrationApi/v1/userRegistrationApi.signUser

UPDATE: After some experiments the status message returned by Google chrome or android device is null , but on Firefox it's not null and working. I don't know what is the reason for that

2

2 Answers

0
votes

The latest chrome version have an issue with this thing. Hope to get it fixed soon in next release or update of chrome. Even i am facing the same issue. A simple workaround would be testing endpoints in other browsers(IE/Firefox/Safari).

Hope this helps.

0
votes

I have found that the problem is Google Chrome new Algorithm maybe it removes some headers to make it's browser faster. The solution is on chrome just don't use it and use any other browser and it should work correctly. But, on Android especially Lollipop (5.0) it's based on Chromenum which is based on Chrome ... the same problem that I faced with google chrome I faced with android and null response was the response. I have changed the user agent for my Google cloud endpoints to Firefox and everything worked correctly.

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);
    }
};

and added it to the api builder

private static UserRegistrationApi mUserRegApi mUserRegBuilder = new UserRegistrationApi.Builder(EnpointConsts.sAndroidHttp, EnpointConsts.sGsonFactory,            CredentialHolder.getCredential()).setApplicationName(Consts.APP_ID).setHttpRequestInitializer(intializer);