我使用AWS API Gateway创建了一个API,但每当我尝试访问任何资源时,都会收到此错误。
有什么想法,为什么会出现这个错误?
Error Domain=com.amazonaws.AWSAPIGatewayErrorDomain Code=1 "(null)" UserInfo={HTTPBody=<CFBasicHash 0x7fd5d87baaf0 [0x102c007b0]>{type = immutable dict, count = 1,
entries =>
0 : message = <CFString 0x7fd5d87bf100 [0x102c007b0]>{contents = "Not able to access resource."}
}
, HTTPHeaderFields=<CFBasicHash 0x7fd5d87bf2a0 [0x102c007b0]>{type = immutable dict, count = 8,
entries =>
0 : X-Cache = <CFString 0x7fd5d87bf030 [0x102c007b0]>{contents = "Error from cloudfront"}
1 : Content-Type = <CFString 0x7fd5d87bd900 [0x102c007b0]>{contents = "application/json"}
3 : x-amzn-RequestId = <CFString 0x7fd5d87baa70 [0x102c007b0]>{contents = "2728fe5f-51b0-11e5-8d25-ada09d3fa091"}
4 : Via = <CFString 0x7fd5d87bcfb0 [0x102c007b0]>{contents = "1.1 87b90692aeeb296771124f5335f08b68.cloudfront.net (CloudFront)"}
6 : Date = <CFString 0x7fd5d87be8d0 [0x102c007b0]>{contents = "Wed, 02 Sep 2015 20:21:11 GMT"}
10 : Content-Length = 43
11 : X-Amz-Cf-Id = <CFString 0x7fd5d87bd0f0 [0x102c007b0]>{contents = "0aL_H-QzchVHBgsYChJ9YwJOs0PKpdFzouXJsDDausqQ9bpunaJmFg=="}
12 : Connection = <CFString 0x7fd5d87be8b0 [0x102c007b0]>{contents = "keep-alive"}
}
}
我的资源需要API密钥,但没有“授权类型”。
这里是我配置客户端的AppDelegate.swift片段:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: nil)
AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration
MYREKSMyreksApiClient.registerClientWithConfiguration(configuration, forKey: "avfhh3FNkh4JDGWG8AHsH4ogucFZjmkEUJIn0C44")
return true
}
下面是我从控制器中调用的方式。
let serviceClient = CLIMyApiClient(forKey: apiKey)
var object = CLICustomObject()
object.param_01 = "Param 01"
object.param_02 = "Param 02"
let result = serviceClient.customObjectPost(contentShare).continueWithBlock{ (task:AWSTask!) -> (AnyObject!) in
if task.error != nil {
print(task.error)
} else {
print("Good!")
}
return nil
}
有什么想法,为什么会出现这个错误?