Skip to content Skip to sidebar Skip to footer

Google Cloud Endpoints Generated IOS Client Not Working

I have a python webservice running locally using GAE Python SDK 1.8.3. After annotating the API and generating iOS client classes using Google Cloud Endpoints Service Generator I'm

Solution 1:

This is an annoying bug from iOS to Endpoints for local testing. I hope they fix it soon. :)

BTW instead of modifying QGTQueryMyAPI.m (which is a generated file). I do Theo's fix just after I create the query instead. So all of my queries that send data look like this (and I set that one flag to switch from localhost to deployed in other places too).

GTLQueryMyApi *query = [GTLQueryMyApi queryForSearchWithObject:someGtlObject];

if (LOCAL_HOST_TESTING) {
    [query setJSON:someGtlObject.JSON];        
}

Solution 2:

This is not a great solution but a patch for now. I have the same problem when doing iOS endpoints localhost testing. However when I use the deployed backend I remove this line and everything is fine.

    auth.shouldAuthorizeAllRequests = YES;

The "resource" key wrapping issue only happens when I add the line above to use localhost. So this morning I'm not using localhost, just the deployed version. Let me know if you fix the issue. :) Obviously pointing to the deployed version is not preferred for testing.


Solution 3:

Alright! user2697002's answer showed me that this works when the webservice is deployed.

For development to work correctly this is the workaround I did.

The generated API uses a template like this for all queries in GTLQueryMyAPI.m

+ (id)queryForSearchWithObject:(GTLMyAPIMessagesSearchRequest *)object {
  if (object == nil) {
    GTL_DEBUG_ASSERT(object != nil, @"%@ got a nil object", NSStringFromSelector(_cmd));
    return nil;
  }
  NSString *methodName = @"myapi.search";
  GTLQueryMyAPI *query = [self queryWithMethodName:methodName];
  query.bodyObject = object;
  query.expectedObjectClass = [GTLMyAPIMessagesContactListResponse class];
  return query;
}

For this to work on development server one could substitute all these lines

query.bodyObject = object;

With

query.JSON = object.JSON;

This stops from wrapping the JSON in a "resource" field. Somehow I believe this shouldn't be done on deployment release version.


Solution 4:

I'm still experimenting but believe this is the proper way (swift) to set up for testing on localhost....

let _service = GTLServiceBackendAPI();
_service.allowInsecureQueries = true;
_service.isRESTDataWrapperRequired = false;
_service.retryEnabled = true;
_service.fetcherService.allowLocalhostRequest = true;
_service.rpcURL = NSURL(string: "http://localhost:8080/_ah/api/rpc?prettyPrint=true")

Post a Comment for "Google Cloud Endpoints Generated IOS Client Not Working"