amazon-web-servicesaws-lambdaaws-api-gatewayaws-sdk-ios

Pass querystring parameters in AWS API Gateway iOS SDK


I have set up an API Gateway for an AWS Lambda function. In the API Gateway I have setup the query string parameter and the request mapping. If I use the test function of the API Gateway I can pass the parameter to my AWS Lambda function.

I have also generated an SDK API for iOS using these instructions.

However, how can I pass my pre-defined query string parameter into this generated API class?

I have also tried using a model, however I do not see a way to pass the model data into the iOS SDK either.


Solution

  • If you have defined your query parameters in your API "Method Request", the SDK should be generated with the query parameters as arguments to your invocation method.

    i.e.

    - (AWSTask *)rootGet:(NSString *)q2 q1:(NSString *)q1 {
        NSDictionary *headerParameters = @{
                                           @"Content-Type": @"application/json",
                                           @"Accept": @"application/json",
    
                                           };
        NSDictionary *queryParameters = @{
                                          @"q2": q2,
                                         @"q1": q1
                                          };
        NSDictionary *pathParameters = @{
    
                                         };
    
        return [self invokeHTTPRequest:@"GET"
                             URLString:@"/"
                        pathParameters:pathParameters
                       queryParameters:queryParameters
                      headerParameters:headerParameters
                                  body:nil
                         responseClass:[FOOEmpty class]];
    }
    

    Keep in mind that if you make changes to your API, the changes will need to be re-deployed to your stage before you re-generate your SDK.