putTableRow method

Future<void> putTableRow({
  1. String? tableName,
  2. String? partitionKey,
  3. String? rowKey,
  4. String? body,
  5. Map<String, dynamic>? bodyMap,
})

Upload or replace table entity/entry.

'tableName',partitionKey and rowKey are all mandatory. body and bodyMap are exclusive and mandatory.

Implementation

Future<void> putTableRow({
  String? tableName,
  String? partitionKey,
  String? rowKey,
  String? body,
  Map<String, dynamic>? bodyMap,
}) async {
  body = _resolveNodeBody(body, bodyMap);
  String path = 'https://${config[accountName]}.table.core.windows.net/$tableName(PartitionKey=\'$partitionKey\', RowKey=\'$rowKey\')';
  var request = http.Request('PUT', Uri.parse(path));
  request.headers['Accept'] = 'application/json;odata=nometadata';
  request.headers['Content-Type'] = 'application/json';
  request.headers['Content-Length'] = '${body!.length}';
  request.body = body;
  _sign4Tables(request);
  var res = await request.send();
  if (res.statusCode >= 200 && res.statusCode < 300) {
    return;
  }
  var message = await res.stream.bytesToString();
  throw AzureStorageException(message, res.statusCode, res.headers);
}