-1

Using AWS API Gateway console, I've generated an IOS SDK for my API. And here is the code I get in the APIClient.m generated

    (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];
     }

How do I call this method and pass it a JSON parameter to send parameters to API ? The code to call the API is

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;
}];

But I don't know how to pass it a POST JSON Paramater as requested by my API ? This question is not a duplicate of Sending an HTTP POST request on iOS as AWS encapsulates its own http classes.

Community
  • 1
  • 1
AlainS
  • 11
  • 3

1 Answers1

0

Based on the generated SDK, your API is not defined to take an input object. You should follow Amazon API Gateway Developer Guide and set up Models and Mapping Templates.

Yosuke
  • 3,759
  • 1
  • 11
  • 21