Integrate /users/{userId} - PATCH method with update-user

  1. Go back to the Resources section of the UsersAPI API in API Gateway console.
  2. Select /users/{userId} resource.
  3. Click Create method.

alt text

  1. In the Create method page - Method details section:
    • Method type: Select UPDATE.
    • Integration type: Keep Lambda function.
    • Lambda function: Choose the update-user function.

alt text

  1. Keep other settings as default.

    • Scroll to the bottom and click Create method.
  2. You will be redirect to the detail of the /users/{userId} - PATCH method.

alt text

  1. Open the Integration request tab.
  2. In the Integration request settings section, click Edit.

alt text

  1. In the Edit integration request page, expand the URL path parameters section:
    • Click Add path parameter.
    • Name: Fill in userId.
    • Mapped from: Fill in method.request.path.userId.

alt text

  1. Expand the Mapping templates section:
    • Click Add mapping template.

    • Content type: Fill in application/json.

    • Template body: Fill in:

      ## Parse the request body into a JSON object
      #set($inputRoot = $input.path('$'))
      {
        #foreach($key in $inputRoot.keySet())
          "$key": "$util.escapeJavaScript($inputRoot.get($key))"#if($foreach.hasNext),#end
        #end,
        "id": "$input.params('userId')"
      }
      

alt text

  1. Scroll to the bottom, click Save.