title: AWS API Gateway - Configuring Integration Request Mapping Templates to accept String body rather JSON
body: <p>I have a spring boot application with GET method like below. This method has input parameter as String that is mapped with path variable {userId}.</p>
  
  <pre><code>@GetMapping("/users/{userId}")
  public String get(@PathVariable ("userId") String userId) {
          return userId;
  }   
  </code></pre>
  
  <p>I created AWS lambda function and uploaded my spring boot JAR. I am able to test lambda fuction with test event after passing string example "userId1". Lambda function worked fine. </p>
  
  <p>Using API gateway, created API, defined resource and GET method. URL looks like below:</p>
  
  <pre><code>/users/{userId} - GET - Integration Request  
  </code></pre>
  
  <p>Also, followed below steps to define Mapping Templates.</p>
  
  <ol>
  <li>Opened the Integration Request settings and then Body Mapping Templates.</li>
  <li>Selected the option: When there are no templates defined (recommended)</li>
  <li>Added a mapping template for: application/json</li>
  <li><p>Added the following template to map the userId to the Lambda input </p>
  
  <p>{
      "userId": "$input.params('userId')"
  }</p></li>
  </ol>
  
  <p>When I test my API, it gives me below exception. I am not sure, how I should define Mapping Templates so that it accepts only String rather JSON. Because my Lambda function and corresponding implemented method accepts only String. Thanks in advance for help. </p>
  
  <pre><code>{
    "errorMessage": "An error occurred during JSON parsing",
    "errorType": "java.lang.RuntimeException",
    "stackTrace": [],
    "cause": {
      "errorMessage": "com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: lambdainternal.util.NativeMemoryAsInputStream@69b2283a; line: 1, column: 1]",
      "errorType": "java.io.UncheckedIOException",
      "stackTrace": [],
      "cause": {
        "errorMessage": "Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: lambdainternal.util.NativeMemoryAsInputStream@69b2283a; line: 1, column: 1]",
        "errorType": "com.fasterxml.jackson.databind.JsonMappingException",
        "stackTrace": [
          "com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:148)",
          "com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:857)",
          "com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:62)",
          "com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:11)",
          "com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1511)",
          "com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1102)"
        ]
      }
    }
  }
  </code></pre>