getObject method
Future<Object>
getObject({
- required String indexName,
- required String objectID,
- List<
String> ? attributesToRetrieve, - RequestOptions? requestOptions,
Retrieves one record by its object ID. To retrieve more than one record, use the objects
operation.
Required API Key ACLs:
- search
Parameters:
indexName
Name of the index on which to perform the operation.objectID
Unique record identifier.attributesToRetrieve
Attributes to include with the records in the response. This is useful to reduce the size of the API response. By default, all retrievable attributes are returned.objectID
is always retrieved. Attributes included inunretrievableAttributes
won't be retrieved unless the request is authenticated with the admin API key.requestOptions
additional request configuration.
Implementation
Future<Object> getObject({
required String indexName,
required String objectID,
List<String>? attributesToRetrieve,
RequestOptions? requestOptions,
}) async {
assert(
indexName.isNotEmpty,
'Parameter `indexName` is required when calling `getObject`.',
);
assert(
objectID.isNotEmpty,
'Parameter `objectID` is required when calling `getObject`.',
);
final request = ApiRequest(
method: RequestMethod.get,
path: r'/1/indexes/{indexName}/{objectID}'
.replaceAll(
'{' r'indexName' '}', Uri.encodeComponent(indexName.toString()))
.replaceAll(
'{' r'objectID' '}', Uri.encodeComponent(objectID.toString())),
queryParams: {
if (attributesToRetrieve != null)
'attributesToRetrieve': attributesToRetrieve,
},
);
final response = await _retryStrategy.execute(
request: request,
options: requestOptions,
);
return deserialize<Object, Object>(
response,
'Object',
growable: true,
);
}