Invoke datazone create_asset_revision from boto3 , error: Invalid JSON provided

0

Hi all,

I am trying to create an asset revision from boto3 but I always obtain the below error, I follow the boto3 documentation and my code looks good according to the required attributes. I tried to use the AWS CLI and I got the same error.

botocore.errorfactory.ValidationException: An error occurred (ValidationException) when calling the CreateAssetRevision operation: Invalid JSON provided

I tested other methods like get_domain, get_asset and these worked, this is my current code:

import boto3
import json

client = boto3.client('datazone')

print("Creating revision")

response = client.create_asset_revision(
    description='description from code',
    formsInput=[
        {
            "content": """ 
                {  "summary" : "This description was uploaded from python code.."}
                """,
            "formName": "AssetCommonDetailsForm",
            'typeIdentifier': 'amazon.datazone.RedshiftViewAssetType',
            'typeRevision': '8'
        }
    ],
    domainIdentifier='dzd_xxxxxxxxxxx',
    identifier='yyyyyyyyyyyyyyyy',
    name='table_name'
)

質問済み 3ヶ月前95ビュー
1回答
1

The ValidationException with the message Invalid JSON provided could be caused by the JSON content not being properly formatted or containing syntax errors. In this case, the mix of single and double quotes in the content value might be causing confusion in the JSON parsing process.

To resolve this issue, ensure that the JSON content within the content key is properly formatted and uses consistent quoting. Use double quotes " for both the keys and values inside the JSON content, and escape any double quotes that are part of the string values. Here's the corrected formsInput section:

    formsInput=[
        {
            "content": "{\"summary\": \"This description was uploaded from python code.\"}",
            "formName": "AssetCommonDetailsForm",
            "typeIdentifier": "amazon.datazone.RedshiftViewAssetType",
            "typeRevision": "8"
        }
    ],
profile picture
エキスパート
回答済み 3ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ