I've been learning Google Endpoints from the tutorial at https://developers.google.com/appengine/docs/java/endpoints/. I got the Endpoint successfully deployed to Google App Engine and I managed to build a simple iPhone app that calls the Endpoint. However, my iPhone app gets the following error when it tries to call the Endpoint:
Error Message
error NSError * domain: @"com.google.GTLJSONRPCErrorDomain" - code: -32099 0x00000001094518a0
_userInfo __NSDictionaryI * 3 key/value pairs 0x00000001094452b0
[0] (null) @"error" : @"java.lang.IndexOutOfBoundsException: Index: 0, Size: 0"
[1] (null) @"NSLocalizedFailureReason" : @"(java.lang.IndexOutOfBoundsException: Index: 0, Size: 0)"
[2] (null) @"GTLStructuredError" : (no summary)
iPhone API Caller (in Objective-C running in Xcode Debugger)
- (IBAction)myButton:(id)sender {
NSInteger myId;
if (self.mySwitch.isOn) {
myId = 0;
}
else {
myId = 1;
}
GTLQueryHelloworld *query = [GTLQueryHelloworld queryForGreetingsGetGreetingWithIdentifier:myId];
[self.helloWorldService executeQuery:query completionHandler:^(GTLServiceTicket *ticket, id object, NSError *error) {
if (!error) {
[self.myLabel setText:object];
}
else {
[self.myLabel setText:[error description]]; // This line gets called
}
}];
}
I found the same error message reported in Youtube video upload fails after 100 % progress for some users with Backend Error code:-32099 but that pertained to calling YouTube and it was eventually closed as a bug that was fixed. So I don't think it's related.
I believe the bug is on the client side because I put some logging on the server (Java) and it does not appear to get called:
public class Greetings {
private static final Logger log = Logger.getLogger(Greetings.class.getName());
public static ArrayList<HelloGreeting> greetings = new ArrayList<HelloGreeting>();
static {
log.setLevel(Level.INFO);
greetings.add(new HelloGreeting("hello world!"));
greetings.add(new HelloGreeting("goodbye world!"));
}
public HelloGreeting getGreeting(@Named("id") Integer id) {
log.info("HelloGreeting called with getGreeting");
log.info("getGreeting id " + id);
return greetings.get(id);
}
I don't see "HelloGreeting called with getGreeting" in my Google server logs, all I see is the log message indicating that my Endpoint project was successfully deployed:
21:56:45.639 Endpoints: https://1-war-dot-firstendpointproject.appspot.com/_ah/api/helloworld@v1 Saved
I've also confirmed I can successfully test the helloworld.greetings.getGreeting API from the deployed API explorer for my project:
https://1-war-dot-firstendpointproject.appspot.com/_ah/api/explorer
When I call the API from the Explorer it generates a log message:
24.130.150.54 - - [19/Jun/2014:21:17:45 -0700] "POST /_ah/spi/com.google.appengine.samples.helloendpoints.Greetings.getGreeting HTTP/1.1" 200 93 "https://1-war-dot-firstendpointproject.appspot.com/ah/api/static/proxy.html?jsh=m%3B%2F%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.htta44JhPmg.O%2Fm%3D__features__%2Fam%3DAQ%2Frt%3Dj%2Fd%3D1%2Fz%3Dzcms%2Frs%3DAItRSTPk1CJ1YqUCyb-H-zhkQTjKPZwvbQ" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/537.75.14" "1-war-dot-firstendpointproject.appspot.com" ms=17 cpu_ms=87 cpm_usd=0.000010 instance=00c61b117ce13f56d6eb483511c2c1bcd24241 app_engine_release=1.9.6
It does not generate "HelloGreeting called with getGreeting" but I suspect that is because I have not configured the logger. At any rate, when my client calls the Endpoint I get no log message at all. Since the API explorer call at least generates 1 log message, I suspect the problem is on the client.
Questions:
1] Is the error I'm seeing generated on the client or the server side?
2] Do you know what array this error is refering to?
3] What are some techniques for debugging a connection problem like this?
Thanks for your help StackOverflowers!
Michael