

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

# BatchPutAssetPropertyValue API
<a name="ingest-api-batch-putasset"></a>

使用 [BatchPutAssetPropertyValue](https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_BatchPutAssetPropertyValue.html) 操作上傳您的資料。透過此操作，您可以一次上傳多個資料項目，以從多個裝置收集資料，並在單一請求中傳送所有資料。

**重要**  
[BatchPutAssetPropertyValue](https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_BatchPutAssetPropertyValue.html) 操作受下列配額限制：  
每個請求最多 10 個[項目](https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_BatchPutAssetPropertyValue.html#API_BatchPutAssetPropertyValue_RequestSyntax)。
每個項目最多 10 個[屬性值](https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_PutAssetPropertyValueEntry.html#iotsitewise-Type-PutAssetPropertyValueEntry-propertyValues) (TQV 資料點）。
AWS IoT SiteWise 拒絕時間戳記為過去 7 天以上或未來超過 10 分鐘的任何資料。
 如需這些配額的詳細資訊，請參閱 *AWS IoT SiteWise API 參考*中的 [BatchPutAssetPropertyValue](https://docs.aws.amazon.com/iot-sitewise/latest/APIReference/API_BatchPutAssetPropertyValue.html)。

若要識別資產屬性，請指定下列其中一項：
+ 資料傳送到的資產屬性`propertyId`的 `assetId`和 。
+ `propertyAlias`，這是資料串流別名 （例如 `/company/windfarm/3/turbine/7/temperature`)。若要使用這個選項，您必須先設定您的資產屬性別名。若要設定屬性別名，請參閱 [管理 的資料串流 AWS IoT SiteWise](manage-data-streams.md)。

以下範例示範如何從儲存在 JSON 檔案的承載中，設定風力渦輪機的溫度和每分鐘旋轉 (RPM) 讀數。

```
aws iotsitewise batch-put-asset-property-value --cli-input-json file://batch-put-payload.json
```

中的範例承載`batch-put-payload.json`具有下列內容。

```
{
  "enablePartialEntryProcessing": true,      
  "entries": [
    {
      "entryId": "{{unique entry ID}}",
      "propertyAlias": "/company/windfarm/3/turbine/7/temperature",
      "propertyValues": [
        {
          "value": {
            "integerValue": 38
          },
          "timestamp": {
            "timeInSeconds": 1575691200
          }
        }
      ]
    },
    {
      "entryId": "{{unique entry ID}}",
      "propertyAlias": "/company/windfarm/3/turbine/7/rpm",
      "propertyValues": [
        {
          "value": {
            "doubleValue": 15.09
          },
          "timestamp": {
            "timeInSeconds": 1575691200
          },
          "quality": "GOOD"
        }
      ]
    },
    {
  "entryId": "unique entry ID",
      "propertyAlias": "/company/windfarm/3/turbine/7/rpm",
      "propertyValues": [
        {
  "value": {
  "nullValue":{"valueType": "D"}
          },
          "timestamp": {
  "timeInSeconds": 1575691200
          },
          "quality": "BAD"
        }
      ]
    }
  ]
}
```

指定 `enablePartialEntryProcessing`為 `true` 允許擷取不會導致失敗的所有值。預設行為是 `false`。如果值無效，則整個項目的擷取會失敗。

承載中的每個項目都包含 `entryId`，您可以將其定義為任何獨特的字串。如果有任何請求項目失敗，每個錯誤都會包含對應請求的 `entryId`，這樣您就可以知道要重試哪些請求。

`propertyValues` 清單中的每個結構都是時間戳記品質值 (TQV) 結構，其中包含一個 `value`、一個 `timestamp`，以及選擇性地包含一個 `quality`。
+ `value` – 包含下列其中一個欄位的結構，取決於所設定屬性的類型：
  + `booleanValue`
  + `doubleValue`
  + `integerValue`
  + `stringValue`
  + `nullValue`
+ `nullValue` – 具有下列欄位的結構，表示值為 Null 且品質為 `BAD`或 的屬性值類型`UNCERTAIN`。
  + `valueType` – {"B"、"D"、"S"、"I"} 的列舉
+ `timestamp` – 包含目前 Unix epoch 時間的結構，以秒為單位`timeInSeconds`，。如果您有時間精確的資料，您也可以在 `timestamp`結構中設定`offsetInNanos`金鑰。 AWS IoT SiteWise 會拒絕過去 7 天或未來 10 分鐘以上時間戳記的任何資料點。
+ `quality` – （選用） 下列其中一個品質字串：
  + `GOOD` – （預設） 資料不會受到任何問題的影響。
  + `BAD` – 資料會受到感應器故障等問題的影響。
  + `UNCERTAIN` – 資料受到感應器不準確等問題的影響。

  如需如何在運算中 AWS IoT SiteWise 處理資料品質的詳細資訊，請參閱[公式表達式中的資料品質](expression-tutorials.md#data-quality)。