Generate answered questions for topic API

I’m trying to use BatchCreateTopicReviewedAnswer API to populate topic with custom questions and receive

{
    "ResponseMetadata": {
        "RequestId": "59ddcbe5-c755-4df7-9f52-7c07a9c5c6c7",
        "HTTPStatusCode": 200,
        "HTTPHeaders": {
            "date": "Mon, 16 Dec 2024 14:30:07 GMT",
            "content-type": "application/json",
            "content-length": "193",
            "connection": "keep-alive",
            "x-amzn-requestid": "59ddcbe5-c755-4df7-9f52-7c07a9c5c6c7"
        },
        "RetryAttempts": 0
    },
    "Status": 200,
    "TopicId": "jLEKMjqpl32vLflnzYSo8e4Z7pf4s0Bg",
    "SucceededAnswers": [],
    "InvalidAnswers": [
        {
            "AnswerId": "hello",
            "Error": "MISSING_REQUIRED_FIELDS"
        }
    ],
    "RequestId": "59ddcbe5-c755-4df7-9f52-7c07a9c5c6c7"
}

Seems like some fields are missing but I have added all the required field from doc
AnswerId, DatasetArn, Question

Some assistance will be much appreciated.

1 Like

Hello @bshevtsov, I am curious to see what the answer definition you imported looks like. The first thing I notice is that it is showing the invalid answer with an AnswerId of “hello”. Have you tried generating a random UUID and using that for any required ID fields instead?

With a little more information about the issue you are facing, I can help guide you further. Thank you!

Yep, you were right. Thanks for help!

Oh, no you’re not :sweat_smile:
I thought it helped after receiving “DUPLICATED_ANSWER” error, but after changing an answer still getting invalid json with “AnswerId”: “e3ddb8a1-7fd2-412a-9919-87c921cf6b91”

Hello @bshevtsov, can you show me a sample JSON for one of the answers you tried to batch create? That would make it easier to resolve the errors.

Sure,
aws quicksight batch-create-topic-reviewed-answer --aws-account-id 06101111119 --topic-id jLEKMjqpl31111lnzYSo8e4Z7pf4s0Bg --answers '[{"AnswerId": "e3ddb8a1-7fd2-412a-9919-87c921cf6b91", "DatasetArn": "arn:aws:quicksight:us-east-1:061051111149:dataset/4ab37b92-10bc-446e-a7dc-d71111c6fbbd", "Question": "Which products have the biggest changes in volume?"}]'
This is cli command but I have also tested it with the python script

Hello @bshevtsov, I see now. I tested this on my end and you are missing a required field. Within the answers array, it is also expecting information for the fields you want it to reference. I was looking at the documentation, and it requires this section to be included:

If you include the required details for each field you want the response to reference, then the error should be resolved. Let me know if you have any further questions!

That’s the thing I was suspecting, yes, thanks. But in this documentation this field is marked as not required CreateTopicReviewedAnswer - Amazon QuickSight

Hello @bshevtsov, that is really interesting. It seems like there may be a bug with this, or maybe the documentation isn’t correct. I would try including some values for Mir parameter and see if it continues to provide the same error message. I am curious if it will resolve the issue.

I’m not sure Mir is the problem, cause I have created a couple of the Answers manually, and describe-answers cli request returned json where mir is null and primaryVisuals were populated.
But anyway, what’s strange is that I thought primaryVisuals should be populated automatically during batch-create-topic-reviewed-answer, since what’s the purpose of Q then ?

Also, the case where we create answers manually on one of the accounts and store their artifacts(as json) somewhere may work for us. A question here is once using that json to import topics/answers in other accounts we should update datasetArn value. Is there a way to do it programmatically, like in bundle-import-job cli with overrideParameters?

Hi @bshevtsov,
It’s been awhile since last communication on this thread. Did you have any additional questions regarding your post or were you able to find a work around?

If we do not hear back within the next 3 business days, I’ll close out this topic.

Thank you!

I do not see my last question was answered. Issue is still present

Hi @bshevtsov,
As this seems as though this may be a bug, I would suggest creating a support ticket with AWS to receive further more in depth assistance.