getTableRow method

Future<String> getTableRow({
  1. String? tableName,
  2. String? partitionKey,
  3. String? rowKey,
  4. List<String>? fields,
})

get data from azure tables

'tableName','partitionKey' and 'rowKey' are all mandatory. If no fields are specified, all fields attached to the entry are returned

Implementation

Future<String> getTableRow(
    {String? tableName,
    String? partitionKey,
    String? rowKey,
    List<String>? fields}) async {
  String selectParams = _resolveNodeParams(fields);
  String path =
      'https://${config[accountName]}.table.core.windows.net/$tableName(PartitionKey=\'$partitionKey\',RowKey=\'$rowKey\')?\$select=$selectParams';
//    print('get path: $path'); //DEBUG LOG
  var request = http.Request('GET', Uri.parse(path));
  request.headers['Accept'] = 'application/json;odata=nometadata';
  request.headers['Content-Type'] = 'application/json';
  request.headers['Accept-Charset'] = 'UTF-8';
  request.headers['DataServiceVersion'] = '3.0;NetFx';
  request.headers['MaxDataServiceVersion'] = '3.0;NetFx';
  _sign4Tables(request);
  var res = await request.send();
  if (res.statusCode >= 200 && res.statusCode < 300) {
    var message = await res.stream.bytesToString();
    return message;
  }
  var message = await res.stream.bytesToString();
  throw AzureStorageException(message, res.statusCode, res.headers);
}