使用AWS API Gateway控制台,我为我的API生成了IOS SDK。这是我在APIClient.m
生成的
(AWSTask *)getpositionsPost {
NSDictionary *headerParameters = @{
@"Content-Type": @"application/json",
@"Accept": @"application/json",
};
NSDictionary *queryParameters = @{
};
NSDictionary *pathParameters = @{
};
return [self invokeHTTPRequest:@"POST"
URLString:@"/getpositions"
pathParameters:pathParameters
queryParameters:queryParameters
headerParameters:headerParameters
body:nil
responseClass:APIEmpty class];
}
如何调用此方法并将其传递给JSON参数以将参数发送到API?调用API的代码是
APIClient *client = APIClient defaultClient;
[client getpositionsPost continueWithBlock:^id(AWSTask *task) {
if (task.error) {
NSLog(@"Error: %@", task.error);
return nil;
}
if (task.result) {
APIEmpty * output = task.result;
NSLog(@"Result: %@", task.result);
//Do something with output
}
return nil;
}];
但我不知道如何按照API的要求传递POST JSON Paramater? 此问题与Sending an HTTP POST request on iOS不重复,因为AWS封装了自己的http类。