

# API Gateway 中 REST API 的参数映射源参考
<a name="rest-api-parameter-mapping-sources"></a>

创建参数映射时，可以指定要修改的方法请求或集成响应参数，并指定如何修改这些参数。

下表显示了可以映射的方法请求参数以及用于创建映射的表达式。在这些表达式中，*name* 是方法请求参数的名称。例如，要映射请求标头参数 `puppies`，请使用表达式 `method.request.header.puppies`。您的表达式必须与正则表达式 `'^[a-zA-Z0-9._$-]+$]'` 匹配。您可以在代理和非代理集成的集成请求中使用参数映射。


| **映射的数据来源** | **映射表达式** | 
| --- | --- | 
| 方法请求路径 | method.request.path.name | 
| 方法请求查询字符串 | method.request.querystring.name | 
| 多值方法请求查询字符串 | method.request.multivaluequerystring.name | 
| 方法请求标头 | method.request.header.name | 
| 多值方法请求标头 | method.request.multivalueheader.name | 
| 方法请求正文 | method.request.body | 
| 方法请求正文 (JsonPath) | `method.request.body.JSONPath_EXPRESSION`. *JSONPath\$1EXPRESSION* 是请求正文的 JSON 字段的 JSONPath 表达式。有关更多信息，请参阅 [JSONPath expression](http://goessner.net/articles/JsonPath/index.html#e2)。  | 
| 阶段变量 | stageVariables.name | 
| 上下文变量 |  `context.name` 名称必须为[受支持的上下文变量](api-gateway-mapping-template-reference.md#context-variable-reference)之一。 | 
| 静态值 | `'static_value'`. *static\$1value* 为字符串文本值，必须括在一对单引号内。例如 `'https://www.example.com'`。 | 

下表显示了可以映射的集成响应参数以及用于创建映射的表达式。在这些表达式中，*name* 是集成响应参数的名称。您可以从任何集成响应标头或集成响应正文、\$1context 变量或静态值映射方法响应标头。要将参数映射用于集成响应，您需要使用非代理集成。


| 映射数据源 | 映射表达式 | 
| --- | --- | 
| 集成响应标头 | integration.response.header.name | 
| 集成响应标头 | integration.response.multivalueheader.name | 
| 集成响应正文 | integration.response.body | 
| 集成响应正文 (JsonPath) | `integration.response.body.JSONPath_EXPRESSION` *JSONPath\$1EXPRESSION* 是响应正文的 JSON 字段的 JSONPath 表达式。有关更多信息，请参阅 [JSONPath expression](http://goessner.net/articles/JsonPath/index.html#e2)。 | 
| 阶段变量 | stageVariables.name | 
| 上下文变量 |  `context.name` 名称必须为[受支持的上下文变量](api-gateway-mapping-template-reference.md#context-variable-reference)之一。 | 
| 静态值 | ` 'static_value'` *static\$1value* 为字符串文本值，必须括在一对单引号内。例如 `'https://www.example.com'`。 | 