

支援終止通知：2025 年 11 月 13 日， AWS 將停止對 Amazon Elastic Transcoder 的支援。2025 年 11 月 13 日之後，您將無法再存取 Elastic Transcoder 主控台或 Elastic Transcoder 資源。

如需轉換至 的詳細資訊 AWS Elemental MediaConvert，請造訪此[部落格文章](https://aws.amazon.com/blogs/media/how-to-migrate-workflows-from-amazon-elastic-transcoder-to-aws-elemental-mediaconvert/)。

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

# 向 Elastic Transcoder 提出 HTTP 請求
<a name="making-http-requests"></a>

Elastic Transcoder REST 請求是 RFC 2616 中定義的 HTTPS 請求。(如需詳細資訊，請前往 [http://www.ietf.org/rfc/rfc2616.txt](http://www.ietf.org/rfc/rfc2616.txt)。) 本節說明 Elastic Transcoder REST 請求的結構。如需可執行動作的詳細說明，請參閱[管道操作](operations-pipelines.md)、[任務操作](operations-jobs.md)和[預設集操作](operations-presets.md)。

典型的 REST 動作包含將 HTTPS 請求傳送至 Elastic Transcoder 並等待回應。如同任何 HTTP 請求，對 Elastic Transcoder 的 REST 請求包含請求方法、URI、請求標頭，有時還包括查詢字串或請求內文。回應包含 HTTP 狀態碼、回應標題，有時還包括回應內文。

**Topics**
+ [HTTP 標頭內容](#http-request-header)
+ [HTTP 請求內文](#http-request-body)
+ [HTTP 回應](#http-response-header)

## HTTP 標頭內容
<a name="http-request-header"></a>

Elastic Transcoder 需要 HTTP 請求標頭中的下列資訊：

**主機 (必要)**  
Elastic Transcoder 端點，可指定資源的建立位置。該值必須為已命名的區域端點。建議您針對 Amazon S3 儲存貯體和 Elastic Transcoder 管道和任務使用相同的端點。如果您使用不同的端點，在包含 Amazon S3 儲存貯體的區域與 Elastic Transcoder 進行編碼的區域之間傳輸的資料，將產生額外費用。此外，資料傳輸所需的時間將延遲對轉碼後檔案的存取。  
如需支援的 Elastic Transcoder 端點清單，請前往 *Amazon Web Services 一般參考*中的[區域和端點](https://docs.aws.amazon.com/general/latest/gr/rande.html#elastictranscoder_region)區段。  
如需跨區域費用的詳細資訊，請參閱 [Amazon S3 定價中的資料傳輸定價](https://aws.amazon.com/s3/pricing/)。

**x-amz-date 或日期 (必要)**  
用來建立包含在 `Authorization` 標題中的簽章的日期。使用 ISO 8601 標準格式以 UTC 時間指定日期，如下所示：`X-Amz-Date: 20130613T203622Z`。  
您必須包含 `x-amz-date` 或 `Date`。(有些 HTTP 用戶端程式庫不讓您設定 `Date` 標頭)。當 `x-amz-date` 標題存在時，系統會在驗證請求時略過任何 `Date` 標題。  
當收到請求時，時間戳記必須在 AWS 系統時間的 15 分鐘內。若為非，請求失敗並發生 `RequestExpired` 錯誤碼，以防止其他人重播您的請求。

**授權 (必要)**  
請求驗證所需的資訊。如需建構此標頭的詳細資訊，請參閱[簽署請求](signing-requests.md)。

**內容類型 (條件)**  
指定 JSON 和版本，例如 `Content-Type: application/x-amz-json-1.0`。  
條件：POST 請求為必要。

**內容長度 (條件)**  
根據 RFC 2616 的訊息長度 (無標題)。  
條件：如果請求內文本身包含資訊 (大多數工具組將自動新增此標題)，則為必填項目。

以下是建立管道之 HTTP 請求的範例標頭。

```
POST /2012-09-25/pipelines HTTP/1.1
host: elastictranscoder.us-east-1.amazonaws.com:443
x-amz-date: 20120116T174952Z
Authorization: AWS4-HMAC-SHA256 Credential=AccessKeyID/20120116/us-east-1/elastictranscoder/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=145b1567ab3c50d929412f28f52c45dbf1e63ec5c66023d232a539a4afd11fd9
content-type: application/x-amz-json-1.0
content-length: 231
connection: Keep-Alive
```

## HTTP 請求內文
<a name="http-request-body"></a>

許多 Elastic Transcoder API 動作會要求您在請求內文中包含 JSON 格式的資料。JSON 符合 Elastic Transcoder 結構描述。

**注意**  
請求內文中的 JSON 值為字串。

**Example 請求**  
以下範例使用簡單的 JSON 陳述式，建立將名為 `sample.mp4` 的檔案轉碼並儲存為 `sams-birthday.mp4` 的任務。  

```
POST /2012-09-25/jobs HTTP/1.1
Content-Type: application/json; charset=UTF-8
Accept: */*
Host: elastictranscoder.us-east-1.amazonaws.com:443
Content-Length: 300
 
{
   "Input":{
      "Key":"sample.mp4",
      "FrameRate":"auto",
      "Resolution":"auto",
      "AspectRatio":"auto",
      "Interlaced":"auto",
      "Container":"mp4"
   },
   "OutputKeyPrefix":"family-videos/",
   "Outputs":[
      {
         "Key":"sams-birthday.mp4",
         "ThumbnailPattern":"thumbnails/sams-birthday-{count}",
         "Rotate":"0",
         "PresetId":"1351620000000-100080"
      }
   ],
   "PipelineId":"1111111111111-abcde1"
}
```

## HTTP 回應
<a name="http-response-header"></a>

所有 Elastic Transcoder API 動作都會在回應中包含 JSON 格式的資料。JSON 符合 Elastic Transcoder 結構描述。

**注意**  
回應中的 JSON 值為字串。

以下為 HTTP 回應中一些重要的標頭，以及在應用程式中如何應用他們，如果適用的話：

**HTTP/1.1**  
此標頭後面有狀態碼。狀態碼 `200` 表示操作成功。如需錯誤代碼的詳細資訊，請參閱 [API 錯誤代碼 (用戶端和伺服器錯誤)](error-handling.md#api-error-codes)。  
類型：字串

**x-amzn-RequestId**  
Elastic Transcoder 建立的值，可唯一識別您的請求，例如 K2QH8DNOU907N97FNA2GDLL8OBVV4KQNSO5AEMVJF66Q9ASUAAJG。如果 Elastic Transcoder 發生問題，AWS 可以使用此值來故障診斷問題。建議您將這些值記錄下來。  
類型：字串

**Content-Length**  
回應內文的長度，以位元組為單位。  
類型：字串

**日期**  
Elastic Transcoder 回應的日期和時間，例如 `Sun, 25 Mar 2012 12:00:00 GMT`。日期格式必須是 RFC 2616 第 3.3 節中規定的完整日期格式之一 。  
類型：字串