[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-09-03 UTC。"],[[["\u003cp\u003eAPI clients can pass request headers, query parameters, form data, XML/JSON payloads, and request paths to the API Gateway.\u003c/p\u003e\n"],["\u003cp\u003eBackend services return response headers and XML/JSON payloads to the API client.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003ex-google-backend\u003c/code\u003e extension in the OpenAPI spec defines the backend service URL, with options to specify the address and path.\u003c/p\u003e\n"],["\u003cp\u003eAPI Gateway uses path translation strategies, either \u003ccode\u003eAPPEND_PATH_TO_ADDRESS\u003c/code\u003e or \u003ccode\u003eCONSTANT_ADDRESS\u003c/code\u003e, to translate client request URLs into backend service URLs.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003epath_translation\u003c/code\u003e default value depends on where \u003ccode\u003ex-google-backend\u003c/code\u003e is used in the OpenAPI specification, being \u003ccode\u003eAPPEND_PATH_TO_ADDRESS\u003c/code\u003e at the top level and \u003ccode\u003eCONSTANT_ADDRESS\u003c/code\u003e at the operation level.\u003c/p\u003e\n"]]],[],null,["# Passing data to and from the backend service\n============================================\n\nWhen an API client makes a request to your API deployed on API Gateway,\nthe client can pass any or all of the following information as part of the request:\n\n- Request headers\n- Query params\n- Form data\n- XML or JSON payloads\n- Request paths\n\nIn building its response to the API request, the backend service can return data\nto the API client, including:\n\n- Response headers\n- XML or JSON payloads\n\nThis document describes how this data is passed to and from the backend service.\n\nHow is request data passed to the backend service?\n--------------------------------------------------\n\nAll data in the request from the API client is passed unchanged to the backend service.\nIt is then up to the backend service to parse the request data as part of handling the request.\n\nHow is response data returned to the API client?\n------------------------------------------------\n\nAll data received in the response from the backend service is passed\nunchanged to the API client. It is then up to the API client to process any\nreturned data in the response.\n\nHow is the request URL passed to the backend service?\n-----------------------------------------------------\n\nThe URL used to make a request to the backend service is controlled by the\n[`x-google-backend`](/endpoints/docs/openapi/openapi-extensions#x-google-backend) extension.\nThis section describes the options for configuring the backend service URL.\n\n### Setting the backend service address and path in the OpenAPI spec\n\nIn the OpenAPI spec that you use to create an API config, you use the\n`x-google-backend` extension to specify the URL of the backend service.\nFor example, you specify the backend service in the form:\n\nIn these examples:\n\n1. \u003cvar translate=\"no\"\u003eGCP_REGION\u003c/var\u003e specifies the Google Cloud region for the deployed backend.\n2. \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e specifies the Google Cloud project ID.\n3. \u003cvar translate=\"no\"\u003eHASH\u003c/var\u003e specifies the unique hash code generated when the Cloud Run service is created.\n\nIn addition, the `path` parameter in the OpenAPI spec specifies the endpoint, or *resource* ,\nsupported by your API. You can specify an absolute path or one that uses\n[path parameters](https://swagger.io/docs/specification/2-0/describing-parameters/#path-parameters):\n\n### Generating the backend service URL from an API request\n\nAs API Gateway handles a request from the API client, it takes the request URL\nsent by the API client and translates it into the URL used to make the request to the backend service.\nExactly how this translation occurs depends on which *path translation strategy* you are using.\n\nThe `path_translation` option to the `x-google-backend` extension supports two path translation strategies:\n\n- `APPEND_PATH_TO_ADDRESS`: The backend service URL is generated by appending the\n resource path from the client request to the `address` URL of the `x-google-backend`\n extension.\n\n Most backend services use `APPEND_PATH_TO_ADDRESS` because it means the backend receives\n the same resource path as specified by the API client.\n- `CONSTANT_ADDRESS`: The backend service URL is constant, as defined by the\n `address` URL of the `x-google-backend` extension. If the client request contains a resource path,\n the resource path is added to the backend service URL by using query parameters.\n\n This method is typically used by [Cloud Run functions](/functions/docs).\n\nFor example:\n\n- `APPEND_PATH_TO_ADDRESS`\n - `address`: `https://`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.appspot.com`\n - Without OpenAPI path parameters:\n - OpenAPI path: `/hello`\n - API client request resource path: `/hello`\n - Backend service request URL: `https://`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.appspot.com/hello`\n - With OpenAPI path parameters:\n - OpenAPI path: `/hello/{name}`\n - API client request resource path: `/hello/Dave`\n - Backend service request URL: `https://`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.appspot.com/hello/Dave`\n- `CONSTANT_ADDRESS`\n - `address`: `https://`\u003cvar translate=\"no\"\u003eGCP_REGION\u003c/var\u003e`-`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.cloudfunctions.net/hello`\n - Without OpenAPI path parameters\n - OpenAPI path: `/hello`\n - API client request resource path: `/hello`\n - Backend service request URL: `https://`\u003cvar translate=\"no\"\u003eGCP_REGION\u003c/var\u003e`-`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.cloudfunctions.net/hello`\n - With OpenAPI path parameters\n - OpenAPI path: `/hello/{name}`\n - API client request resource path: `/hello/Dave`\n - Backend service request URL: `https://`\u003cvar translate=\"no\"\u003eGCP_REGION\u003c/var\u003e`-`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.cloudfunctions.net/hello?name=Dave`\n\n### Setting `path_translation`\n\nSet `path_translation` as part of setting `x-google-backend`: \n\n```\nx-google-backend:\n address: https://GCP_REGION-PROJECT_ID.cloudfunctions.net/hello\n path_translation: [ APPEND_PATH_TO_ADDRESS | CONSTANT_ADDRESS ]`\n```\n\nThe default value of `path_translation` depends on where you set `x-google-backend`\nin your OpenAPI spec:\n\n- When `x-google-backend` is used at the top level of the OpenAPI specification,\n `path_translation` defaults to `APPEND_PATH_TO_ADDRESS`.\n\n- When `x-google-backend` is used at the operation level of the OpenAPI specification,\n `path_translation` defaults to `CONSTANT_ADDRESS`."]]