如何解决来自带有 iOS SDK 的 AWS API Gateway API 的空响应Objective-C
我正在调用一个简单的 AWS API Gateway API(AWS 文档中描述的 SimpleCalc API 示例)。我可以通过网络浏览器和 curl 成功调用它。但是当我通过生成的 iOS SDK 调用它时,响应为空。我正在遵循以下说明:
https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-use-sdk-ios-objc.html
我修改了示例代码以使用匿名凭据而不是 Cognito:
AWSAnonymousCredentialsProvider *creds = [[AWSAnonymousCredentialsProvider alloc] init];
AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast2 credentialsProvider:creds];
AWSServiceManager.defaultServiceManager.defaultServiceConfiguration = configuration;
SIMPLE_CALCSimpleCalcClient *client = [SIMPLE_CALCSimpleCalcClient defaultClient];
调用调用 GET 方法:
[[client rootGet:@"+" a:@"2" b:@"1"] continueWithBlock:^id _Nullable(AWSTask * _Nonnull task) {
NSString *result = @"";
if (task.error != nil) {
result = [NSString stringWithFormat:@"Error: %@",task.error.description];
} else if (task.result != nil && [task.result isKindOfClass:[SIMPLE_CALCResponse class]]) {
SIMPLE_CALCResponse *response = (SIMPLE_CALCResponse *)task.result;
result = [NSString stringWithFormat:@"%@ %@ %@ = %@\n(full response: %@)",response.input.a,response.input.op,response.input.b,response.output.c,response];
}
NSLog(result);
return nil;
}];
task.result
非零,但 task.result.input
和 task.result.output
都是空的。
我可以在 CloudWatch 中看到 Lambda 正在接收正确的参数并返回正确的响应。但不知何故,当客户端打印出来时,响应是空的。客户端是否配置不正确? API Gateway 配置中是否有需要更改的内容?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。