

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 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 表達式](http://goessner.net/articles/JsonPath/index.html#e2)。  | 
| 階段變數 | stageVariables.name | 
| 環境變數 |  `context.name` 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 表達式](http://goessner.net/articles/JsonPath/index.html#e2)。 | 
| 階段變數 | stageVariables.name | 
| 環境變數 |  `context.name` name 必須是[支援的環境變數](api-gateway-mapping-template-reference.md#context-variable-reference)之一。 | 
| 靜態值 | ` 'static_value'` *static\$1value* 是字串常值，而且前後必須加上單引號。例如 `'https://www.example.com'`。 | 