createContent method

Future<CreateContentResponse> createContent({
  1. required String knowledgeBaseId,
  2. required String name,
  3. required String uploadId,
  4. String? clientToken,
  5. Map<String, String>? metadata,
  6. String? overrideLinkOutUri,
  7. Map<String, String>? tags,
  8. String? title,
})

Creates Wisdom content. Before to calling this API, use StartContentUpload to upload an asset.

May throw AccessDeniedException. May throw ConflictException. May throw ResourceNotFoundException. May throw ServiceQuotaExceededException. May throw ValidationException.

Parameter knowledgeBaseId : The identifier of the knowledge base. This should not be a QUICK_RESPONSES type knowledge base if you're storing Wisdom Content resource to it. Can be either the ID or the ARN. URLs cannot contain the ARN.

Parameter name : The name of the content. Each piece of content in a knowledge base must have a unique name. You can retrieve a piece of content using only its knowledge base and its name with the SearchContent API.

Parameter uploadId : A pointer to the uploaded asset. This value is returned by StartContentUpload.

Parameter clientToken : A unique, case-sensitive identifier that you provide to ensure the idempotency of the request. If not provided, the Amazon Web Services SDK populates this field. For more information about idempotency, see Making retries safe with idempotent APIs.

Parameter metadata : A key/value map to store attributes without affecting tagging or recommendations. For example, when synchronizing data between an external system and Wisdom, you can store an external version identifier as metadata to utilize for determining drift.

Parameter overrideLinkOutUri : The URI you want to use for the article. If the knowledge base has a templateUri, setting this argument overrides it for this piece of content.

Parameter tags : The tags used to organize, track, or control access for this resource.

Parameter title : The title of the content. If not set, the title is equal to the name.

Implementation

Future<CreateContentResponse> createContent({
  required String knowledgeBaseId,
  required String name,
  required String uploadId,
  String? clientToken,
  Map<String, String>? metadata,
  String? overrideLinkOutUri,
  Map<String, String>? tags,
  String? title,
}) async {
  final $payload = <String, dynamic>{
    'name': name,
    'uploadId': uploadId,
    'clientToken': clientToken ?? _s.generateIdempotencyToken(),
    if (metadata != null) 'metadata': metadata,
    if (overrideLinkOutUri != null) 'overrideLinkOutUri': overrideLinkOutUri,
    if (tags != null) 'tags': tags,
    if (title != null) 'title': title,
  };
  final response = await _protocol.send(
    payload: $payload,
    method: 'POST',
    requestUri:
        '/knowledgeBases/${Uri.encodeComponent(knowledgeBaseId)}/contents',
    exceptionFnMap: _exceptionFns,
  );
  return CreateContentResponse.fromJson(response);
}